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); }
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); }
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); }
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); }
public void ShouldNotFailOnDoubleDisposeTest() { MockRuntimeInterception mockRuntimeInterception; mockRuntimeInterception = new MockRuntimeInterception(); Assert.IsNotNull(mockRuntimeInterception); mockRuntimeInterception.Dispose(); mockRuntimeInterception.Dispose(); }