public void TestEntryExitRetValFn() { MockAspect.Reset(); TestIntFn(); Assert.AreEqual(1, MockAspect.Entries, "OnEntry"); Assert.AreEqual(1, MockAspect.Exits, "OnExit"); }
public void TestEntryExit() { MockAspect.Reset(); CallMe(); Assert.AreEqual(1, MockAspect.Entries, "OnEntry"); Assert.AreEqual(1, MockAspect.Exits, "OnExit"); }
public void TestInstanceEqual() { MockAspect.Reset(); DummyClass dc = new DummyClass(); bool called = false; MockAspect.OnEntryAction = (args) => { called = true; Assert.AreSame(args.Instance, dc, "object reference mismatch"); }; dc.Call(); Assert.IsTrue(called); // Assert that dc == Property }
public void TestMethodArguments() { bool called = false; MockAspect.Reset(); MockAspect.OnEntryAction = (MethodArguments a) => { Assert.AreEqual(1, a.Arguments.Count); Assert.AreEqual("SomeValue", a.Arguments[0].Value); Assert.AreEqual("value", a.Arguments[0].Name); Assert.AreEqual(typeof(string), a.Arguments[0].Type); called = true; }; CallMeMaybe("SomeValue"); Assert.IsTrue(called); }
public void TestMethodException() { bool called = false; MockAspect.Reset(); MockAspect.OnExceptionAction = (args, e) => { called = true; Assert.AreEqual(e.Message, "Blah"); }; try { CallMeException(); } catch (Exception e) // because the exception will rethrow after { Assert.AreEqual(e.Message, "Blah"); Assert.IsTrue(called); return; // } Assert.Fail(); }