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