public void GetHashCode_NullKey_GetHashCodeInvocationNotNeeded()
        {
            var spy = new EqualitySpy();
            IEqualityComparer <EqualitySpy> subject = new SelectorEqualizer <EqualitySpy, string>(s => s.FakeASelector <string>(null));

            subject.GetHashCode(spy);

            Assert.That(spy.GetHashCodeCalled, Is.False);
        }
        public void Equals_NoKeyIsNull_EqualsInvoked()
        {
            EqualitySpy spyForX = new EqualitySpy(), spyForY = new EqualitySpy();
            Func <string, EqualitySpy> eachSpyToEachLetter = s => s.Equals("x") ? spyForX : spyForY;

            IEqualityComparer <string> subject = new SelectorEqualizer <string, EqualitySpy>(eachSpyToEachLetter);

            subject.Equals("x", "y");
            Assert.That(spyForX.EqualsCalled, Is.True);
            Assert.That(spyForY.EqualsCalled, Is.True);
        }
        public void Equals_OneKeyNull_SelectedEqualsNotCalled()
        {
            EqualitySpy spyForX = new EqualitySpy(), spyForY = new EqualitySpy();
            Func <string, EqualitySpy> spyXForX = s => s.Equals("x") ? spyForX : null;
            Func <string, EqualitySpy> spyYForY = s => s.Equals("y") ? spyForY : null;

            IEqualityComparer <string> subject = new SelectorEqualizer <string, EqualitySpy>(spyXForX);

            subject.Equals("x", "y");
            Assert.That(spyForX.EqualsCalled, Is.False);

            subject = new SelectorEqualizer <string, EqualitySpy>(spyYForY);
            subject.Equals("x", "y");
            Assert.That(spyForY.EqualsCalled, Is.False);
        }