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
Hello I have an litte problem.
I could not get Isolate.Verify.NonPublic.WasCalled working as expected.

My Testcase:
[TestMethod]
        [Isolated]
        public void SaveStatusFullTest()
        {
            BaseEntityForTest<EntityIdKey> target = new BaseEntityForTest<EntityIdKey>(new EntityIdKey(123));
            PrivateObject privateObject = new PrivateObject(target, new PrivateType(typeof(BaseEntity<EntityIdKey>)));
            BaseEntity_Accessor<EntityIdKey> accessor = new BaseEntity_Accessor<EntityIdKey>(privateObject);
            target.TestValue = "Status Full Test";
            accessor._originalValues = new SortedList<string> { { "TestValue", "Ein alter Wert" } };
            accessor.State = EntityState.Full;
            Isolate.NonPublic.WhenCalled(DatabaseAccess_Accessor.ShadowedType.ReferencedType, "UpdateDatabaseObject").IgnoreCall();
            target.Save();
            Isolate.Verify.NonPublic.WasCalled(DatabaseAccess_Accessor.ShadowedType.ReferencedType, "UpdateDatabaseObject");
            Isolate.Verify.NonPublic.WasNotCalled(DatabaseAccess_Accessor.ShadowedType.ReferencedType, "InsertDatabaseObject");
            Assert.AreEqual(EntityState.Full, target.State);
            Assert.AreEqual("Status Full Test", target.TestValue);
            Assert.AreEqual("Status Full Test", accessor._originalValues["TestValue"]);
        }


DatabaseAccess is an internal static class so I used the Accessor to get the type.

target.Save(); calls DatabaseAccess.UpdateDatabaseObject();

Isolate.NonPublic.WhenCalled(DatabaseAccess_Accessor.ShadowedType.ReferencedType, "UpdateDatabaseObject").IgnoreCall() is working fine when replaced with an DoInstead this is also working fine.

Isolate.Verify.NonPublic.WasCalled(DatabaseAccess_Accessor.ShadowedType.ReferencedType, "UpdateDatabaseObject") always failes

Does anyone know the reason?

Regards
Michael
asked by swtrse (4k points)

4 Answers

0 votes
Hi Michael,

Private accessors have some quircks.
We'll investigate and get back to you.

Thanks,

Gil
answered by gilz (14.5k points)
0 votes
Hi Michael,

I checked it out on a simple test and the verification with private accessors should work.
Is it possible to send us a small solution that reproduces the problem so we can check it out?
I'm sending you a mail from our support.
answered by ohad (35.5k points)
0 votes
I made an litte Testproject to replay the error.

Well I found out that if there are only normal Methods the Validate just works as expected.
It looks like i has something to do with the generic part of the Methods.

For the latest Test I used Isolator 5.4.5.0

I uploaded the Testsolution that can reproduce the error at http://www.schoeller-soft.net/TestConsole.7z
answered by swtrse (4k points)
0 votes
Hi Micheal,
Thanks for the repro. It's a bug, we'll let you know once it is fixed.
answered by ohad (35.5k points)
...