Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        public void ShouldNotFailOnDoubleDisposeTest()
        {
            MockAspectDynamicInvoker mockAspectDynamicInvoker;

            mockAspectDynamicInvoker = new MockAspectDynamicInvoker();

            Assert.IsNotNull(mockAspectDynamicInvoker);

            mockAspectDynamicInvoker.Dispose();
            mockAspectDynamicInvoker.Dispose();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }