Can you please tell the scenario when the object returned could be different from the setup object?
The Object Id
set during debugging in Setup
is different when src code is executed.
interface IBaseClass
{
IFactory aFactory;
}
class Point
{
Point(int x, int y)
{
this.x = x;
this.y = y;
}
int x;
int y;
}
interface Factory
{
public AnObject create(string a, Point pt);
}
Test Code
var anObjectMock = new Mock<AnObject> { DefaultValue = DefaultValue.Mock };
var sMatcher = It.Is<string>(s => s.Equals("aString"));
var ptMatcher = It.Is<Point>(p => (p.x == CONST_X && p.y == CONST_Y));
var FactoryMock = Mock.Get<IFactory>(IBaseClassMock.Object.Factory);
FactoryMock.Setup(f => f.create(sMatcher, ptMatcher)).Returns(anObjectMock.Object); // Say ObjectId is #1
SRC
Object obj = BasicImaging.Factory.create("aString", new Point(CONST_X, CONST_Y));
// Getting no ObjectId