chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
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.
asked by fvanomme (1.6k points)

1 Answer

0 votes
Hello,

I'm trying as best as I can to reproduce your test case locally, but I'm obviously missing some context. Would it be possible for you to send us a small solution demonstrating the problem? Please send it to support at typemock.com

Thanks very much!
answered by igal (5.7k points)
...