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); }
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); }
public void ShouldEqualsInvokeOnObjectTest() { 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.Equals(null)); invocationParameters = new object[] { null }; mockDynamicInvoker = new MockDynamicInvoker(); returnValue = mockDynamicInvoker.BypassInvokeOnObject(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters); Assert.AreEqual(false, returnValue); }
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); }
public void ShouldNotFailOnDoubleDisposeTest() { MockDynamicInvoker mockDynamicInvoker; mockDynamicInvoker = new MockDynamicInvoker(); Assert.IsNotNull(mockDynamicInvoker); mockDynamicInvoker.Dispose(); mockDynamicInvoker.Dispose(); }
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); }
public void ShouldFailOnNullProxyTypeInvokeOnObjectTest() { MockDynamicInvoker mockDynamicInvoker; object proxyInstance; Type proxiedType; MethodInfo invokedMethodInfo; object[] invocationParameters; proxyInstance = new object(); proxiedType = null; invokedMethodInfo = (MethodInfo)MemberInfoProxy<IMockObject>.GetLastMemberInfo(exec => exec.GetType()); invocationParameters = new object[] { }; mockDynamicInvoker = new MockDynamicInvoker(); mockDynamicInvoker.BypassInvokeOnObject(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters); }
public void ShouldFailOnNullMethodInfoInvokeTest() { MockDynamicInvoker mockDynamicInvoker; object proxyInstance; Type proxiedType; MethodInfo invokedMethodInfo; object[] invocationParameters; proxyInstance = new object(); proxiedType = typeof(IMockObject); invokedMethodInfo = null; invocationParameters = new object[] { }; mockDynamicInvoker = new MockDynamicInvoker(); mockDynamicInvoker.BypassInvokeOnObject(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters); }
public void ShouldFailOnBadMethodNameInvokeOnObjectTest() { MockDynamicInvoker mockDynamicInvoker; object proxyInstance; Type proxiedType; MethodInfo invokedMethodInfo; object[] invocationParameters; proxyInstance = new object(); proxiedType = typeof(IMockObject); invokedMethodInfo = (MethodInfo)typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic); invocationParameters = new object[] { }; mockDynamicInvoker = new MockDynamicInvoker(); mockDynamicInvoker.BypassInvokeOnObject(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters); }
public void ShouldFailOnBadInputParameterCountToStringInvokeOnObjectTest() { MockDynamicInvoker mockDynamicInvoker; object proxyInstance; Type proxiedType; MethodInfo invokedMethodInfo; object[] invocationParameters; proxyInstance = new object(); proxiedType = typeof(IMockObject); invokedMethodInfo = (MethodInfo)MemberInfoProxy<IMockObject>.GetLastMemberInfo(exec => exec.ToString()); invocationParameters = new object[] { 0 }; mockDynamicInvoker = new MockDynamicInvoker(); mockDynamicInvoker.BypassInvokeOnObject(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters); }
public void ShouldFailOnBadDeclaringTypeInvokeOnObjectTest() { MockDynamicInvoker mockDynamicInvoker; object proxyInstance; Type proxiedType; MethodInfo invokedMethodInfo; object[] invocationParameters; proxyInstance = new object(); proxiedType = typeof(IDisposable); invokedMethodInfo = (MethodInfo)MemberInfoProxy<IDisposable>.GetLastMemberInfo(exec => exec.Dispose()); invocationParameters = new object[] { }; mockDynamicInvoker = new MockDynamicInvoker(); mockDynamicInvoker.BypassInvokeOnObject(proxiedType, invokedMethodInfo, proxyInstance, invocationParameters); }