public void TestEntryExit() { TestAspect.Reset(); CallMe(); Assert.AreEqual(TestAspect.Entries, 1); Assert.AreEqual(TestAspect.Exits, 1); }
public void TestMethodArguments() { bool called = false; TestAspect.Reset(); TestAspect.OnEntryAction = (MethodArguments a) => { Assert.AreEqual(a.Arguments.Count, 1); Assert.AreEqual(a.Arguments[0], "SomeValue"); called = true; }; CallMeMaybe("SomeValue"); Assert.IsTrue(called); }
public void TestUseThisAttribute() { TestAspect.Reset(); DummyClass dc = new DummyClass(); bool called = false; TestAspect.InspectInstance = (inst) => { called = true; Assert.AreSame(inst, dc, "object reference mismatch"); }; dc.Call(); Assert.IsTrue(called); // Assert that dc == Property }
public void TestMethodException() { bool called = false; TestAspect.Reset(); TestAspect.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(); }