Esempio n. 1
0
        public void ShouldDisposeInvokeTest()
        {
            MockDynamicInvoker mockDynamicInvoker;
            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[] { };

            mockDynamicInvoker = new MockDynamicInvoker();
            returnValue = mockDynamicInvoker.Invoke(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters);

            Assert.IsNull(returnValue);
            Assert.IsTrue(mockDynamicInvoker.Disposed);
        }
Esempio n. 2
0
        public void ShouldCloneInvokeTest()
        {
            MockDynamicInvoker mockDynamicInvoker;
            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[] { };

            mockDynamicInvoker = new MockDynamicInvoker();
            returnValue = mockDynamicInvoker.Invoke(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters);

            Assert.IsNull(returnValue);
            Assert.AreEqual("ICloneable::Clone", mockDynamicInvoker.lastOperationName);
        }
Esempio n. 3
0
        public void ShouldToStringInvokeTest()
        {
            MockDynamicInvoker mockDynamicInvoker;
            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[] { };

            mockDynamicInvoker = new MockDynamicInvoker();
            returnValue = mockDynamicInvoker.Invoke(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters);

            Assert.AreEqual(typeof(IMockObject).FullName, returnValue);
        }
Esempio n. 4
0
        public void ShouldFailOnNullTargetInstanceInvokeTest()
        {
            MockDynamicInvoker mockDynamicInvoker;
            object proxyInstance;
            Type proxiedType;
            MethodInfo invokedMethodInfo;
            object[] invocationParameters;

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

            mockDynamicInvoker = new MockDynamicInvoker();
            mockDynamicInvoker.Invoke(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters);
        }