public void TestThatGetHashCodeThrowsArgumentNullExceptionIfNameObjectIsNull()
        {
            var comparer = new NameTargetComparer();

            Assert.That(comparer, Is.Not.Null);

            Assert.Throws <ArgumentNullException>(() => comparer.GetHashCode(null));
        }
        public void TestThatGetHashCodeGetsHashCode()
        {
            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 namedObject = fixture.CreateAnonymous <INamedObject>();

            Assert.That(comparer.GetHashCode(namedObject), Is.EqualTo(namedObject.NameTarget.GetHashCode()));

            namedObject.AssertWasCalled(m => m.NameTarget, opt => opt.Repeat.Times(3));
        }
        public void TestThatGetHashCodeThrowsDeliveryEngineSystemExceptionIfTargetNameOnNamedObjectIsNull()
        {
            var fixture = new Fixture();

            fixture.Customize <INamedObject>(e => e.FromFactory(() =>
            {
                var nameObjectMock = MockRepository.GenerateMock <INamedObject>();
                nameObjectMock.Expect(m => m.NameTarget)
                .Return(null)
                .Repeat.Any();
                return(nameObjectMock);
            }));

            var comparer = new NameTargetComparer();

            Assert.That(comparer, Is.Not.Null);

            var namedObject = fixture.CreateAnonymous <INamedObject>();

            Assert.Throws <DeliveryEngineSystemException>(() => comparer.GetHashCode(namedObject));

            namedObject.AssertWasCalled(m => m.NameTarget, opt => opt.Repeat.Times(2));
        }