コード例 #1
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);
		}
コード例 #2
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);
		}
コード例 #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);
		}
コード例 #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);
		}
コード例 #5
0
		public void ShouldNotFailOnDoubleDisposeTest()
		{
			MockRuntimeInterception mockRuntimeInterception;

			mockRuntimeInterception = new MockRuntimeInterception();

			Assert.IsNotNull(mockRuntimeInterception);

			mockRuntimeInterception.Dispose();
			mockRuntimeInterception.Dispose();
		}