Esempio n. 1
0
		public void ShouldCloneInvokeTest()
		{
			MockRuntimeInterception mockRuntimeInterception;
			IRuntimeInvocation mockRuntimeInvocation;
			IRuntimeContext mockRuntimeContext;
			object proxyInstance;
			Type proxiedType;
			MethodInfo invokedMethodInfo;
			object[] invocationParameters;
			object returnValue;

			proxyInstance = new object();
			proxiedType = typeof(IMockCloneable);
			invokedMethodInfo = typeof(IMockCloneable).GetMethod("Clone");
			invocationParameters = new object[] { };
			mockRuntimeInvocation = new RuntimeInvocation(proxyInstance, proxiedType, invokedMethodInfo, invocationParameters, null);
			mockRuntimeContext = null;

			mockRuntimeInterception = new MockRuntimeInterception();
			mockRuntimeInterception.Invoke(mockRuntimeInvocation, mockRuntimeContext);
			returnValue = mockRuntimeInvocation.InvocationReturnValue;

			Assert.IsNull(returnValue);
			Assert.AreEqual("IMockCloneable::Clone", mockRuntimeInterception.LastOperationName);
		}
Esempio n. 2
0
		public void ShouldDisposeInvokeTest()
		{
			MockRuntimeInterception mockRuntimeInterception;
			IRuntimeInvocation mockRuntimeInvocation;
			IRuntimeContext mockRuntimeContext;
			object proxyInstance;
			Type proxiedType;
			MethodInfo invokedMethodInfo;
			object[] invocationParameters;
			object returnValue;

			proxyInstance = new object();
			proxiedType = typeof(IDisposable);
			invokedMethodInfo = typeof(IDisposable).GetMethod("Dispose");
			invocationParameters = new object[] { };
			mockRuntimeInvocation = new RuntimeInvocation(proxyInstance, proxiedType, invokedMethodInfo, invocationParameters, null);
			mockRuntimeContext = null;

			mockRuntimeInterception = new MockRuntimeInterception();
			mockRuntimeInterception.Invoke(mockRuntimeInvocation, mockRuntimeContext);
			returnValue = mockRuntimeInvocation.InvocationReturnValue;

			Assert.IsNull(returnValue);
			Assert.IsTrue(mockRuntimeInterception.Disposed);
		}
Esempio n. 3
0
		public void ShouldFailOnNullInputParameterInvokeTest()
		{
			MockRuntimeInterception mockRuntimeInterception;
			IRuntimeInvocation mockRuntimeInvocation;
			IRuntimeContext mockRuntimeContext;
			object proxyInstance;
			Type proxiedType;
			MethodInfo invokedMethodInfo;
			object[] invocationParameters;

			proxyInstance = new object();
			proxiedType = typeof(IMockObject);
			invokedMethodInfo = typeof(IMockObject).GetMethod("ToString");
			invocationParameters = null;
			mockRuntimeInvocation = new RuntimeInvocation(proxyInstance, proxiedType, invokedMethodInfo, invocationParameters, null);
			mockRuntimeContext = null;

			mockRuntimeInterception = new MockRuntimeInterception();
			mockRuntimeInterception.Invoke(mockRuntimeInvocation, mockRuntimeContext);
		}
Esempio n. 4
0
		public void ShouldToStringInvokeTest()
		{
			MockRuntimeInterception mockRuntimeInterception;
			IRuntimeInvocation mockRuntimeInvocation;
			IRuntimeContext mockRuntimeContext;
			object proxyInstance;
			Type proxiedType;
			MethodInfo invokedMethodInfo;
			object[] invocationParameters;
			object returnValue;

			proxyInstance = new object();
			proxiedType = typeof(IMockObject);
			invokedMethodInfo = typeof(IMockObject).GetMethod("ToString");
			invocationParameters = new object[] { };
			mockRuntimeInvocation = new RuntimeInvocation(proxyInstance, proxiedType, invokedMethodInfo, invocationParameters, null);
			mockRuntimeContext = null;

			mockRuntimeInterception = new MockRuntimeInterception();
			mockRuntimeInterception.Invoke(mockRuntimeInvocation, mockRuntimeContext);
			returnValue = mockRuntimeInvocation.InvocationReturnValue;

			Assert.AreEqual(typeof(IMockObject).FullName, returnValue);
		}