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
0 votes
I set up these two mocks:
var intReader = Isolate.Fake.Instance<IRecordsReader>();
            Isolate.WhenCalled(() => intReader.GetDbType()).WillReturn("Integer");

            var ntextReader = Isolate.Fake.Instance<IRecordsReader>();
            Isolate.WhenCalled(() => ntextReader.GetDbType()).WillReturn("Ntext");


But when I run the test I get this error:
TypeMock.VerifyException:
TypeMock Verification: Call to IRecordsReader.GetDbType() Parameter: 1
passed object [Mock0000IRecordsReader]
is not the same instance as expected [Mock0000IRecordsReader].


As stated this worked fine in 5.2.1 but I finally got around to upgrading to 5.2.3 and now the test doesn't work.
Any idea why?
asked by slace (2.4k points)

4 Answers

0 votes
Slace,

Can you post the full test here (or a complete test that recreates the issue)? It seems like a mix up happens somewhere between verification methods, but I need to see the complete scenario to understand what happened.

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Sure, the code isn't super useful as it's a bit out-of-context, but here it is:

var intReader = Isolate.Fake.Instance<IRecordsReader>();
            Isolate.WhenCalled(() => intReader.GetDbType()).WillReturn("Integer");

            var ntextReader = Isolate.Fake.Instance<IRecordsReader>();
            Isolate.WhenCalled(() => ntextReader.GetDbType()).WillReturn("Ntext");

DocTypeObjectBuilder target = new DocTypeObjectBuilder(string.Empty);
            var intProp = target.BuildProperty(intReader);
            var ntextProp = target.BuildProperty(ntextReader);

Assert.AreEqual(typeof(int), intProp.DatabaseType);
            Assert.AreEqual(typeof(string), ntextProp.DatabaseType);



The error is happening on the second time I do Isolate.WhenCalled, I don't get passed there.
answered by slace (2.4k points)
0 votes
slace,

I couldn't recreate the issue from the test code (I tried the first 4 lines before you sent the rest and it worked as well). Would it be possible for you to send our support mailbox a small solution recreating this? The error message itself is very strange and I for one did not encounter this sort of behavior.

Doron
Typemock Support
answered by doron (17.2k points)
0 votes
I'll see if i can create it outside of the current project I'm having the bug in (to see if it's reproducable)
answered by slace (2.4k points)
...