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(nameof(IDisposable.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.IsDisposed); }
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(object).GetMethod(nameof(this.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(MockRuntimeInterception).FullName, returnValue); }
public void ShouldCloneInvokeTest() { MockRuntimeInterception mockRuntimeInterception; IRuntimeInvocation mockRuntimeInvocation; IRuntimeContext mockRuntimeContext; object proxyInstance; Type proxiedType; MethodInfo invokedMethodInfo; object[] invocationParameters; object returnValue; proxyInstance = new MockCloneable(); proxiedType = typeof(IMockCloneable); invokedMethodInfo = typeof(IMockCloneable).GetMethod(nameof(IMockCloneable.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 ShouldNotFailOnDoubleDisposeTest() { MockRuntimeInterception mockRuntimeInterception; mockRuntimeInterception = new MockRuntimeInterception(); Assert.IsNotNull(mockRuntimeInterception); mockRuntimeInterception.Dispose(); mockRuntimeInterception.Dispose(); }
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(nameof(this.ToString)); invocationParameters = null; mockRuntimeInvocation = new RuntimeInvocation(proxyInstance, proxiedType, invokedMethodInfo, invocationParameters, null); mockRuntimeContext = null; mockRuntimeInterception = new MockRuntimeInterception(); mockRuntimeInterception.Invoke(mockRuntimeInvocation, mockRuntimeContext); }