public void GetHashCode_InvokedOverKey()
        {
            IEqualityComparer <string> subject = new SelectorEqualizer <string, string>(s => s.ToLower());

            Assert.That(subject.GetHashCode("DANIEL"), Is.EqualTo("daniel".GetHashCode()));
            Assert.That(subject.GetHashCode("DANIEL"), Is.Not.EqualTo("someoneElse".GetHashCode()));
        }
        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 Explore()
        {
            IEqualityComparer <EqualitySubject> subject = new SelectorEqualizer <EqualitySubject, int>(s => s.I);

            Assert.That(subject.Equals(new EqualitySubject {
                I = 1
            }, new EqualitySubject {
                I = 2
            }), Is.False);
            Assert.That(subject.GetHashCode(new EqualitySubject {
                I = 1
            }), Is.EqualTo(1.GetHashCode()));

            IEqualityComparer <EqualitySubject> byDAndI = new SelectorEqualizer <EqualitySubject, decimal>(s => s.D)
                                                          .Then(s => s.I);

            byDAndI = Eq <EqualitySubject> .By(s => s.D)
                      .Then(s => s.I);
        }
        public void GetHashCode_NullKey_Zero()
        {
            IEqualityComparer <string> subject = new SelectorEqualizer <string, string>(s => null);

            Assert.That(subject.GetHashCode("whatever"), Is.EqualTo(0));
        }