Ejemplo n.º 1
0
 public void TestEntryExit()
 {
     TestAspect.Reset();
     CallMe();
     Assert.AreEqual(TestAspect.Entries, 1);
     Assert.AreEqual(TestAspect.Exits, 1);
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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
        }
Ejemplo n.º 4
0
        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();
        }