Ejemplo n.º 1
0
        public void CanGetHashCode()
        {
            var id     = Guid.Empty;
            var testee = new ConcreteEntity(id);

            testee.GetHashCode().Should().Be(391); // (17 * 23) + 0
        }
Ejemplo n.º 2
0
        public void Test_GetHashCode_identical_between_proxy_and_raw_instances()
        {
            var raw   = new ConcreteEntity();
            var proxy = EntityProxyFactory.CreateProxy(raw);

            // the proxy and raw instance are not the same
            Assert.IsFalse(ReferenceEquals(raw, proxy));

            var x = raw.GetHashCode();
            var y = proxy.GetHashCode();

            // hash codes are same
            Assert.AreEqual(x, y);
        }
Ejemplo n.º 3
0
		public void Test_GetHashCode_identical_between_proxy_and_raw_instances()
		{
			var raw = new ConcreteEntity();
			var proxy = EntityProxyFactory.CreateProxy(raw);

			// the proxy and raw instance are not the same
			Assert.IsFalse(ReferenceEquals(raw, proxy));

			var x = raw.GetHashCode();
			var y = proxy.GetHashCode();

			// hash codes are same
			Assert.AreEqual(x, y);
		}
Ejemplo n.º 4
0
        public void Two_entities_with_the_same_Id_should_equal_each_other()
        {
            var first = new ConcreteEntity { Id = 99 };
            var second = new ConcreteEntity { Id = 99 };

            first.Equals(second).ShouldBeTrue();
            second.Equals(first).ShouldBeTrue();

            Equals(first, second).ShouldBeTrue();
            Equals(second, first).ShouldBeTrue();

            first.GetHashCode().ShouldEqual(second.GetHashCode());

            (first == second).ShouldBeTrue();
            (second == first).ShouldBeTrue();

            (first != second).ShouldBeFalse();
            (second != first).ShouldBeFalse();
        }
Ejemplo n.º 5
0
        public void Two_entities_with_different_Ids_should_not_equal_each_other()
        {
            var first = new ConcreteEntity { Id = 66 };
            var second = new ConcreteEntity { Id = 77 };

            first.Equals(second).ShouldBeFalse();
            second.Equals(first).ShouldBeFalse();

            Equals(first, second).ShouldBeFalse();
            Equals(second, first).ShouldBeFalse();

            first.GetHashCode().ShouldNotEqual(second.GetHashCode());

            (first == second).ShouldBeFalse();
            (second == first).ShouldBeFalse();

            (first != second).ShouldBeTrue();
            (second != first).ShouldBeTrue();
        }
Ejemplo n.º 6
0
        public void Two_entities_with_the_same_Id_should_equal_each_other()
        {
            var first = new ConcreteEntity {
                Id = 99
            };
            var second = new ConcreteEntity {
                Id = 99
            };

            first.Equals(second).ShouldBeTrue();
            second.Equals(first).ShouldBeTrue();


            Equals(first, second).ShouldBeTrue();
            Equals(second, first).ShouldBeTrue();

            first.GetHashCode().ShouldEqual(second.GetHashCode());

            (first == second).ShouldBeTrue();
            (second == first).ShouldBeTrue();

            (first != second).ShouldBeFalse();
            (second != first).ShouldBeFalse();
        }
Ejemplo n.º 7
0
        public void Two_entities_with_different_Ids_should_not_equal_each_other()
        {
            var first = new ConcreteEntity {
                Id = 66
            };
            var second = new ConcreteEntity {
                Id = 77
            };

            first.Equals(second).ShouldBeFalse();
            second.Equals(first).ShouldBeFalse();


            Equals(first, second).ShouldBeFalse();
            Equals(second, first).ShouldBeFalse();

            first.GetHashCode().ShouldNotEqual(second.GetHashCode());

            (first == second).ShouldBeFalse();
            (second == first).ShouldBeFalse();

            (first != second).ShouldBeTrue();
            (second != first).ShouldBeTrue();
        }