I have a test structured as follows (uses typemock 6.0.6):
[TestMethod, Isolated]
public void PrintItemsControllerCreatePrintItem()
{
// Arrange
var fakeDal = Isolate.Fake.Instance<Wlgore>();
Isolate.Swap.AllInstances<Wlgore>().With(fakeDal);
var fakeCn = Isolate.Fake.Instance<Oracle>();
Isolate.Swap.AllInstances<Oracle>().With(fakeCn);
Isolate.WhenCalled(() => fakeDal.GetQualificationItemNumbersAndFormats(fakeCn, FormatType.Box)).DoInstead(context => { return new ItemNumberFormatStub().GetDataReaderStub(); });
Isolate.WhenCalled(() => fakeDal.GetFormats(fakeCn, FormatType.Box)).DoInstead(context => { return new FormatFileStub().GetDataReaderStub(); });
//Isolate.WhenCalled(() => fakeDal.GetQualificationItemNumbers(fakeCn, FormatType.Box, @"\SomeServerSomeDirectoryBOX_FORMAT_1.FMT")).DoInstead(context => { return new SingleItemNumbersStub().GetDataReaderStub(); });
Isolate.WhenCalled(() => fakeDal.GetQualificationItemNumbers(fakeCn, FormatType.Box, "\\SomeServer\SomeDirectory\BOX_FORMAT_1.FMT")).WithExactArguments().DoInstead(context => { return new SingleItemNumbersStub().GetDataReaderStub(); });
Isolate.WhenCalled(() => fakeDal.GetQualificationItemNumbers(fakeCn, FormatType.Box, "\\SomeServer\SomeDirectory\BOX_FORMAT_2.FMT")).WithExactArguments().DoInstead(context => { return new ItemNumbersStub().GetDataReaderStub(); });
Isolate.WhenCalled(() => fakeDal.GetQualificationItemPackageAttributes(fakeCn, "111")).DoInstead(context => { return new SingleItemPkgAttsStub().GetDataReaderStub(); });
// Act
var testObj = Wlgore.LQS.Library.PrintItemsController.GetController();
testObj.FormatType = FormatType.Box;
var newFormatFileFilter = testObj.FormatsFilterList[0].FormatFile;
testObj.FormatFileFilter = newFormatFileFilter;
var itemNumber = testObj.FilteredItemNumbers[0].ItemNumber;
However the last line throws an error as the FilteredItemNumbers list never gets populated by the mock call:
Isolate.WhenCalled(() => fakeDal.GetQualificationItemNumbers(fakeCn, FormatType.Box, "\\SomeServer\SomeDirectory\BOX_FORMAT_1.FMT")).WithExactArguments().DoInstead(context => { return new SingleItemNumbersStub().GetDataReaderStub(); });
The DoInstead call never executes. If the 'WithExactArguments' is removed then the test works as expected. Any pointers or clues as to the issue, would be appreciated.