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
Hi,

I'm trying to make the following code work:

MockManager.Init();

MockObject webSiteMock1 = MockManager.MockObject(typeof(WebSite));
webSiteMock1.ExpectGetAlways("ID", 1);
WebSite site1 = (WebSite)webSiteMock1.Object;

MockObject webSiteMock2 = MockManager.MockObject(typeof(WebSite));
webSiteMock2.ExpectGetAlways("ID", 2);
WebSite site2 = (WebSite)webSiteMock2.Object;

Assert.AreEqual(1, site1.ID);
Assert.AreEqual(2, site2.ID);

MockManager.Verify();


In this example, my concrete class 'WebSite' just has one integer property ID.
My test uses more than one website, so I want multiple website mock objects at the same time, which have different values.

When I run the test, the second assert fails, because site2.ID returns 1 instead of 2. It seems the two mock object got mixed up.
What am I doing wrong? Any ideas?

Kind regards,
David
asked by davidfre (680 points)

3 Answers

0 votes
Hi David,
You have found a BUG :twisted:, thanks for reporting it.
We will fix it and deliver the patch :-)
answered by scott (32k points)
0 votes
Hi Scott,

Thanks for your reply!
I'm looking forward to the patch :)

David
answered by davidfre (680 points)
0 votes
Hi Scott,

The problem is solved in TypeMock 2.3.1, thanks a lot!

However, when installing the new version, I got the following error:

Module C:Program FilesTypeMock.NETTypeMock.NET
egsrv32.trg failed to register.
HRESULT -2147024703. Contact your support personnel.


and

Module C:Program FilesTypeMock.NETTypeMock.NET
egsrv321.trg failed to register.
HRESULT -2147024703. Contact your support personnel.


When I continue the setup, the installation completes and I can use TypeMock.dll.

Thanks again.

David
answered by davidfre (680 points)
...