예제 #1
0
        public void CanGetHashCode()
        {
            var id     = Guid.Empty;
            var testee = new ConcreteEntity(id);

            testee.GetHashCode().Should().Be(391); // (17 * 23) + 0
        }
예제 #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);
        }
예제 #3
0
파일: EntityTests.cs 프로젝트: nhannd/Xian
		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);
		}
        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();
        }
        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();
        }
예제 #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();
        }
예제 #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();
        }