public void TestThatEqualsReturnsFalseIfTargetNameIsNotEqualOnNameObjects() { var fixture = new Fixture(); fixture.Customize <INamedObject>(e => e.FromFactory(() => { var nameObjectMock = MockRepository.GenerateMock <INamedObject>(); nameObjectMock.Expect(m => m.NameTarget) .Return(fixture.CreateAnonymous <string>()) .Repeat.Any(); return(nameObjectMock); })); var comparer = new NameTargetComparer(); Assert.That(comparer, Is.Not.Null); var x = fixture.CreateAnonymous <INamedObject>(); var y = fixture.CreateAnonymous <INamedObject>(); Assert.That(comparer.Equals(x, y), Is.False); x.AssertWasCalled(m => m.NameTarget, opt => opt.Repeat.Times(1)); y.AssertWasCalled(m => m.NameTarget, opt => opt.Repeat.Times(1)); }
public void TestThatEqualsThrowsArgumentNullExceptionIfYIsNull() { var fixture = new Fixture(); fixture.Customize <INamedObject>(e => e.FromFactory(() => MockRepository.GenerateMock <INamedObject>())); var comparer = new NameTargetComparer(); Assert.That(comparer, Is.Not.Null); Assert.Throws <ArgumentNullException>(() => comparer.Equals(fixture.CreateAnonymous <INamedObject>(), null)); }