Hi,
I am new to justmock, bear with me if I have some basic questions wrong.
We have few unit tests that run fine when I run them locally, but when I checkin them in TFS then it fails the gated-checkin.
I know this can be caused from a range of reasons, but I have reason to believe that one of the mocked method is not getting mocked in the server.
Here is how the code looks,
public void My_Failing_Test()
{
Test_Class_Accessor target = new Test_Class_Accessor();
target.DataLayer = GetMockLayer();
// Set up data
Test_Class mockTest = new Test_Class();
Mock.NonPublic.Arrange<
bool
>(mockPharm, "MockedPrivateMethod", ArgExpr.IsAny<
String
>(), ArgExpr.IsAny<
String
>(), ArgExpr.IsAny<
DateTime
>()).IgnoreArguments().IgnoreInstance().Returns(false);
target.UnderTestPrivateMethod();
//Asserts
}
UnderTestPrivateMethod has a call to MockedPrivateMethod
private static DataLayer GetMockLayer(......)
{
Features mockFeatures = Mock.Create<
Features
>(Constructor.NotMocked, Behavior.CallOriginal);
mockFeatures.someThing = new SomeThing{.....};
DataLayer mockLayer = Mock.Create<
DataLayer
>(Constructor.NotMocked, Behavior.CallOriginal);
mockLayer.TwoTier_Initialize();
Mock.Arrange(() => mockLayer.Features).Returns(mockFeatures);
return mockLayer;
}
I suspect for some reason both the mockFeatures.someThing and MockedPrivateMethod are not getting mocked.
Is there something wrong with what I am doing?
If someone has faces similar problem before, please let me know.
Appreciate the time, thanks