public void Should_return_true_for_equals_method_when_fake_managers_are_the_same() { // Arrange var interceptingProxy = new FakedProxyWithManagerSpecified { FakeManager = new FakeManager() }; var proxyPassedToEquals = new FakedProxyWithManagerSpecified { FakeManager = interceptingProxy.FakeManager }; var equalsMethod = typeof(object).GetMethod("Equals", new[] { typeof(object) }); var interceptedCall = A.Fake <IWritableFakeObjectCall>(); A.CallTo(() => interceptedCall.Method).Returns(equalsMethod); A.CallTo(() => interceptedCall.FakedObject).Returns(proxyPassedToEquals); A.CallTo(() => interceptedCall.Arguments).Returns(new ArgumentCollection(new object[] { proxyPassedToEquals }, interceptedCall.Method)); var eventRaiser = A.Fake <ICallInterceptedEventRaiser>(); interceptingProxy.FakeManager.AttachProxy(typeof(FakedProxyWithManagerSpecified), interceptingProxy, eventRaiser); // Act eventRaiser.CallWasIntercepted += Raise.With(new CallInterceptedEventArgs(interceptedCall)).Now; // Assert A.CallTo(() => interceptedCall.SetReturnValue(true)).MustHaveHappened(); }
public void Should_return_true_for_equals_method_when_fake_managers_are_the_same() { // Arrange var interceptingProxy = new FakedProxyWithManagerSpecified { FakeManager = new FakeManager(typeof(int), 0) }; var proxyPassedToEquals = new FakedProxyWithManagerSpecified { FakeManager = interceptingProxy.FakeManager }; var equalsMethod = typeof(object).GetMethod("Equals", new[] { typeof(object) }); var interceptedCall = A.Fake <IInterceptedFakeObjectCall>(); A.CallTo(() => interceptedCall.Method).Returns(equalsMethod); A.CallTo(() => interceptedCall.FakedObject).Returns(proxyPassedToEquals); A.CallTo(() => interceptedCall.Arguments).Returns(new ArgumentCollection(new object[] { proxyPassedToEquals }, interceptedCall.Method)); // Act ProcessFakeObjectCall(interceptingProxy.FakeManager, interceptedCall); // Assert A.CallTo(() => interceptedCall.SetReturnValue(true)).MustHaveHappened(); }