예제 #1
0
        public void ShouldDisposeInvokeTest()
        {
            MockAspectDynamicInvoker mockAspectDynamicInvoker;
            object proxyInstance;
            Type proxiedType;
            MethodInfo invokedMethodInfo;
            object[] invocationParameters;
            object returnValue;

            proxyInstance = new object();
            proxiedType = typeof(IDisposable);
            invokedMethodInfo = (MethodInfo)MemberInfoProxy<IDisposable>.GetLastMemberInfo(exec => exec.Dispose());
            invocationParameters = new object[] { };

            mockAspectDynamicInvoker = new MockAspectDynamicInvoker();
            returnValue = mockAspectDynamicInvoker.Invoke(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters);

            Assert.IsNull(returnValue);
            Assert.IsFalse(mockAspectDynamicInvoker.Disposed);
        }
예제 #2
0
        public void ShouldCloneInvokeTest()
        {
            MockAspectDynamicInvoker mockAspectDynamicInvoker;
            object proxyInstance;
            Type proxiedType;
            MethodInfo invokedMethodInfo;
            object[] invocationParameters;
            object returnValue;

            proxyInstance = new object();
            proxiedType = typeof(ICloneable);
            invokedMethodInfo = (MethodInfo)MemberInfoProxy<ICloneable>.GetLastMemberInfo(exec => exec.Clone());
            invocationParameters = new object[] { };

            mockAspectDynamicInvoker = new MockAspectDynamicInvoker();
            returnValue = mockAspectDynamicInvoker.Invoke(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters);

            Assert.IsNull(returnValue);
            Assert.AreEqual("ICloneable::Clone", mockAspectDynamicInvoker.lastOperationName);
        }
예제 #3
0
        public void ShouldFailOnDisposedInvokeTest()
        {
            MockAspectDynamicInvoker mockAspectDynamicInvoker;
            object proxyInstance;
            Type proxiedType;
            MethodInfo invokedMethodInfo;
            object[] invocationParameters;
            object returnValue;

            proxyInstance = new object();
            proxiedType = typeof(IMockObject);
            invokedMethodInfo = (MethodInfo)MemberInfoProxy<IMockObject>.GetLastMemberInfo(exec => exec.ToString());
            invocationParameters = new object[] { };

            mockAspectDynamicInvoker = new MockAspectDynamicInvoker(new MockObject());
            mockAspectDynamicInvoker.Dispose();
            returnValue = mockAspectDynamicInvoker.Invoke(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters);
        }
예제 #4
0
        public void ShouldNotFailOnDoubleDisposeTest()
        {
            MockAspectDynamicInvoker mockAspectDynamicInvoker;

            mockAspectDynamicInvoker = new MockAspectDynamicInvoker();

            Assert.IsNotNull(mockAspectDynamicInvoker);

            mockAspectDynamicInvoker.Dispose();
            mockAspectDynamicInvoker.Dispose();
        }
예제 #5
0
        public void ShouldFailOnNullMethodInfoInvokeTest()
        {
            MockAspectDynamicInvoker mockAspectDynamicInvoker;
            object proxyInstance;
            Type proxiedType;
            MethodInfo invokedMethodInfo;
            object[] invocationParameters;

            proxyInstance = new object();
            proxiedType = typeof(IMockObject);
            invokedMethodInfo = null;
            invocationParameters = new object[] { };

            mockAspectDynamicInvoker = new MockAspectDynamicInvoker();
            mockAspectDynamicInvoker.Invoke(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters);
        }
예제 #6
0
        public void ShouldFailOnNullInvokingTypeInvokeTest()
        {
            MockAspectDynamicInvoker mockAspectDynamicInvoker;
            object proxyInstance;
            Type proxiedType;
            MethodInfo invokedMethodInfo;
            object[] invocationParameters;

            proxyInstance = new object();
            proxiedType = null;
            invokedMethodInfo = (MethodInfo)MemberInfoProxy<IMockObject>.GetLastMemberInfo(exec => exec.ToString());
            invocationParameters = new object[] { };

            mockAspectDynamicInvoker = new MockAspectDynamicInvoker();
            mockAspectDynamicInvoker.Invoke(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters);
        }