Exemplo n.º 1
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        private static void AssertKeysNotEqual(TypeKey key1, TypeKey key2)
        {
            Assert.That(key1.Equals(key2), Is.False);
            Assert.That(key2.Equals(key1), Is.False);
            Assert.That(key1.Equals((object)key2), Is.False);
            Assert.That(key2.Equals((object)key1), Is.False);
        }
Exemplo n.º 2
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        private static void AssertKeysEqual(TypeKey key1, TypeKey key2)
        {
            var hashCode1 = key1.GetHashCode();
            var hashCode2 = key2.GetHashCode();

            Assert.That(hashCode1, Is.EqualTo(hashCode2));

            Assert.That(key1.Equals(key2), Is.True);
            Assert.That(key2.Equals(key1), Is.True);
            Assert.That(key1.Equals((object)key2), Is.True);
            Assert.That(key2.Equals((object)key1), Is.True);
        }
Exemplo n.º 3
0
        public void CanTestTypeKeysEquality(TypeKey key1, TypeKey key2, bool expectedResult)
        {
            //-- act

            var actualResult1      = key1.Equals(key2);
            var actualResult2      = key2.Equals(key1);
            var actualResult1Op    = (key1 == key2);
            var actualResult2Op    = (key2 == key1);
            var actualResult1NotOp = (key1 != key2);
            var actualResult2NotOp = (key2 != key1);

            var hash1 = key1.GetHashCode();
            var hash2 = key2.GetHashCode();

            //-- assert

            actualResult1.Should().Be(expectedResult);
            actualResult2.Should().Be(expectedResult);
            actualResult1Op.Should().Be(expectedResult);
            actualResult2Op.Should().Be(expectedResult);
            actualResult1NotOp.Should().Be(!expectedResult);
            actualResult2NotOp.Should().Be(!expectedResult);

            if (expectedResult)
            {
                hash2.Should().Be(hash1);
            }
        }
        public void ObjectEquals(object compareObject, bool expected)
        {
            var typeKey = new TypeKey(typeof(string), "Foo");

            var actual = typeKey.Equals(compareObject);

            actual.Should().Be(expected);
        }
Exemplo n.º 5
0
        public override bool Equals(object obj)
        {
            if (!(obj is HaspKey other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(Id.Equals(other.Id) &&
                   InnerId.Equals(other.InnerId) &&
                   Number.Equals(other.Number) &&
                   TypeKey.Equals(other.TypeKey) &&
                   IsHome.Equals(other.IsHome));
        }