Ejemplo n.º 1
0
        public void BasicBeforeOverridenMethodStateful()
        {
            lock (Interception.Handle)
            {
                var _method = Metadata <Overriden> .Method(_Overriden => _Overriden.Method(Argument <int> .Value, Argument <int> .Value));

                var _instance = new Overriden();
                Interception.Initialize();
                _instance.Method(2, 3);
                Assert.AreEqual(Interception.Done, false);
                Aspect.Weave <Before.Interceptor.Parameterized>(_method);
                Interception.Initialize();
                var _return = _instance.Method(2, 3);
                Assert.AreEqual(_return, 1);
                Assert.AreEqual(Interception.Done, true);
                Assert.AreEqual(Interception.Instance, _instance);
                Assert.AreEqual(Interception.Arguments.Length, 2);
                Assert.AreEqual(Interception.Arguments[0], 2);
                Assert.AreEqual(Interception.Arguments[1], 3);
                Aspect.Release <Before.Interceptor.Parameterized>(_method);
                Interception.Initialize();
                _instance.Method(2, 3);
                Assert.AreEqual(Interception.Done, false);
            }
        }
Ejemplo n.º 2
0
 public void BasicBeforeStaticMethod()
 {
     lock (Interception.Handle)
     {
         var _method = Metadata.Method(() => Static.Method(Argument <int> .Value, Argument <int> .Value));
         Interception.Initialize();
         Static.Method(2, 3);
         Assert.AreEqual(Interception.Done, false);
         Aspect.Weave <Before.Interceptor>(_method);
         Interception.Initialize();
         var _return = Static.Method(2, 3);
         Assert.AreEqual(_return, 1);
         Assert.AreEqual(Interception.Done, true);
         Aspect.Release <Before.Interceptor>(_method);
         Interception.Initialize();
         Static.Method(2, 3);
         Assert.AreEqual(Interception.Done, false);
     }
 }
Ejemplo n.º 3
0
        public void BasicBeforeSealedMethod()
        {
            lock (Interception.Handle)
            {
                var _method = Metadata <Sealed> .Method(_Instance => _Instance.Method(Argument <int> .Value, Argument <int> .Value));

                var _instance = new Sealed();
                Interception.Initialize();
                _instance.Method(2, 3);
                Assert.AreEqual(Interception.Done, false);
                Aspect.Weave <Before.Interceptor>(_method);
                Interception.Initialize();
                var _return = _instance.Method(2, 3);
                Assert.AreEqual(_return, 1);
                Assert.AreEqual(Interception.Done, true);
                Aspect.Release <Before.Interceptor>(_method);
                Interception.Initialize();
                _instance.Method(2, 3);
                Assert.AreEqual(Interception.Done, false);
            }
        }
Ejemplo n.º 4
0
 public void BasicBeforeStaticMethodStateful()
 {
     lock (Interception.Handle)
     {
         var _method = Metadata.Method(() => Static.Method(Argument <int> .Value, Argument <int> .Value));
         Interception.Initialize();
         Static.Method(2, 3);
         Assert.AreEqual(Interception.Done, false);
         Aspect.Weave <Before.Interceptor.Parameterized>(_method);
         Interception.Initialize();
         var _return = Static.Method(2, 3);
         Assert.AreEqual(_return, 1);
         Assert.AreEqual(Interception.Done, true);
         Assert.AreEqual(Interception.Instance, null);
         Assert.AreEqual(Interception.Arguments.Length, 2);
         Assert.AreEqual(Interception.Arguments[0], 2);
         Assert.AreEqual(Interception.Arguments[1], 3);
         Aspect.Release <Before.Interceptor.Parameterized>(_method);
         Interception.Initialize();
         Static.Method(2, 3);
         Assert.AreEqual(Interception.Done, false);
     }
 }