Beispiel #1
0
        public void WhenInjectorCreatesInstanceOfWrappableTypeWithCallHandlerAttributes_ThenItUsesTheSuppliedConstructorParameters()
        {
            WrappableWithAttributes wrappable = this.policyInjector.Create <WrappableWithAttributes>();

            wrappable.Method();
            wrappable.Method();
            wrappable.Method3();

            Assert.AreEqual(2, this.callCounter.Calls.Count);
            Assert.AreEqual(2, this.callCounter.Calls["Method"]);
            Assert.AreEqual(1, this.callCounter.Calls["Method3"]);
        }
Beispiel #2
0
        public void WhenInjectorCreatesInstanceOfWrappableTypeWithCallHandlerAttributes_ThenMethodCallsAreIntercepted()
        {
            WrappableWithAttributes wrappable = this.policyInjector.Create <WrappableWithAttributes>();

            wrappable.Method();
            wrappable.Method();
            wrappable.Method3();

            Assert.AreEqual(2, this.callCounter.Calls.Count);
            Assert.AreEqual(2, this.callCounter.Calls["Method"]);
            Assert.AreEqual(1, this.callCounter.Calls["Method3"]);
        }
Beispiel #3
0
        public void WhenInjectorWrapsInstanceOfWrappableTypeWithCallHandlerAttributes_ThenMethodCallsAreIntercepted()
        {
            WrappableWithAttributes wrappable
                = this.policyInjector.Wrap <WrappableWithAttributes>(new WrappableWithAttributes());

            wrappable.Method();
            wrappable.Method();
            wrappable.Method3();

            Assert.AreEqual(2, GlobalCountCallHandler.Calls.Count);
            Assert.AreEqual(2, GlobalCountCallHandler.Calls["Method"]);
            Assert.AreEqual(1, GlobalCountCallHandler.Calls["Method3"]);
        }
Beispiel #4
0
        public void WhenInjectorWrapsInstanceOfWrappableTypeWithCallHandlerAttributesWithNonGenericMethods_ThenMethodCallsAreIntercepted()
        {
            WrappableWithAttributes wrappable =
                (WrappableWithAttributes)this.policyInjector.Wrap(typeof(WrappableWithAttributes), new WrappableWithAttributes());

            wrappable.Method();
            wrappable.Method();
            wrappable.Method3();

            Assert.AreEqual(2, this.callCounter.Calls.Count);
            Assert.AreEqual(2, this.callCounter.Calls["Method"]);
            Assert.AreEqual(1, this.callCounter.Calls["Method3"]);
        }
Beispiel #5
0
        public void CanWrapObjectWithInterceptionAttributesWithNonGenericMethods()
        {
            GlobalCountCallHandler.Calls.Clear();

            WrappableWithAttributes wrappable
                = (WrappableWithAttributes)PolicyInjection.Wrap(typeof(WrappableWithAttributes), new WrappableWithAttributes());

            wrappable.Method();
            wrappable.Method();
            wrappable.Method3();

            Assert.AreEqual(2, GlobalCountCallHandler.Calls.Count);
            Assert.AreEqual(2, GlobalCountCallHandler.Calls["Method"]);
            Assert.AreEqual(1, GlobalCountCallHandler.Calls["Method3"]);
        }
Beispiel #6
0
        public void CanWrapObjectWithInterceptionAttributes()
        {
            GlobalCountCallHandler.Calls.Clear();

            WrappableWithAttributes wrappable
                = PolicyInjection.Wrap <WrappableWithAttributes>(new WrappableWithAttributes());

            wrappable.Method();
            wrappable.Method();
            wrappable.Method3();

            Assert.AreEqual(2, GlobalCountCallHandler.Calls.Count);
            Assert.AreEqual(2, GlobalCountCallHandler.Calls["Method"]);
            Assert.AreEqual(1, GlobalCountCallHandler.Calls["Method3"]);
        }
Beispiel #7
0
        public void CanCreateWrappedObjectWithInterceptionAttributesWithConstructorParameters()
        {
            GlobalCountCallHandler.Calls.Clear();

            WrappableWithAttributes wrappable
                = PolicyInjection.Create <WrappableWithAttributes>(10, "foo");

            wrappable.Method();
            wrappable.Method();
            wrappable.Method3();

            Assert.IsFalse(wrappable.DefaultCtorCalled);
            Assert.AreEqual(2, GlobalCountCallHandler.Calls.Count);
            Assert.AreEqual(2, GlobalCountCallHandler.Calls["Method"]);
            Assert.AreEqual(1, GlobalCountCallHandler.Calls["Method3"]);
        }