public void It_IsEquivilentToMatcher_VerifySuccess_WithDiffereningTypes() { // Given var booMock = new Mock <IBar>(); var foo = new Foo(booMock.Object); var fooParam = new FooParam { Description = "test description", ReferenceNumber = 12345 }; var expectedFooParam = new FooParam { Description = fooParam.Description + "", ReferenceNumber = fooParam.ReferenceNumber }; foo.CallBoo(fooParam); // When booMock.Verify(b => b.ItWorked(It <BarParam> .IsEquivalentTo(expectedFooParam))); // Then // No Exception thrown }
public void It_IsEquivilentToMatcher_VerifyFail_WithDiffereningTypes() { // Given var booMock = new Mock <IBar>(); var foo = new Foo(booMock.Object); var fooParam = new FooParam { Description = "test description", ReferenceNumber = 12345 }; var expectedFooParam = new FooParam { Description = "something else", ReferenceNumber = 54321 }; foo.CallBoo(fooParam); // When, Then var testException = Assert.Throws <MockException>(() => booMock.Verify(b => b.ItWorked(It <BarParam> .IsEquivalentTo(expectedFooParam)), Times.Once) ); Assert.StartsWith("Expected invocation on the mock once, but was 0 times", testException.Message.Trim()); }