Exemplo n.º 1
0
        public void ZeroHasher_ReturnsZero()
        {
            var spy = new EqualitySpy();

            Assert.That(Hasher.Zero(spy), Is.EqualTo(0));

            Assert.That(spy.GetHashCodeCalled, Is.False);
        }
Exemplo n.º 2
0
        public void DefaultHasher_NotNull_InvokedGetHashCodeOnObject()
        {
            var spy = new EqualitySpy();

            Hasher.Default(spy);

            Assert.That(spy.GetHashCodeCalled, Is.True);
        }
Exemplo n.º 3
0
        public void Equals_OneNullArgument_EqualsPredicateInvocationNotNeeded(string first, string second)
        {
            var spy = new EqualitySpy();
            Func <string, string, bool> equal   = spy.GetEquals <string>(true);
            IEqualityComparer <string>  subject = new DelegatedEqualizer <string>(equal, Hasher.Zero);

            subject.Equals(first, second);

            Assert.That(spy.EqualsCalled, Is.False);
        }
Exemplo n.º 4
0
        public void Equals_BothNull_EqualsPredicateInvocationNotNeeded()
        {
            var spy = new EqualitySpy();
            Func <string, string, bool> notEqual = spy.GetEquals <string>(false);
            IEqualityComparer <string>  subject  = new DelegatedEqualizer <string>(notEqual, Hasher.Zero);

            subject.Equals(null, null);

            Assert.That(spy.EqualsCalled, Is.False);
        }
Exemplo n.º 5
0
        public void Ctor_Comparer()
        {
            var spy     = new EqualitySpy();
            var subject = new DelegatedEqualizer <int>(
                spy.GetComparer <int>(-1),
                spy.GetHashCode <int>(42));

            Assert.That(subject.Equals(1, 1), Is.False);
            Assert.That(spy.EqualsCalled, Is.True);
            Assert.That(subject.GetHashCode(1), Is.EqualTo(42));
            Assert.That(spy.GetHashCodeCalled, Is.True);
        }