Exemplo n.º 1
0
        public void EqualWhenTransientIfBothOjectsAreTheSameInstance()
        {
            ClassUsingGuidIdentity p1 = new ClassUsingGuidIdentity();
            ClassUsingGuidIdentity p2 = p1;

            Assert.IsTrue(p1.Equals(p2));
        }
Exemplo n.º 2
0
        public void NotEqualWhenSecondInstanceIsNull()
        {
            ClassUsingGuidIdentity p1 = new ClassUsingGuidIdentity();
            ClassUsingGuidIdentity p2 = null;

            Assert.IsFalse(p1.Equals(p2));
        }
Exemplo n.º 3
0
        public void NotEqualWhenInstancesAreDifferentTypes()
        {
            ClassUsingGuidIdentity p1 = new ClassUsingGuidIdentity();
            int i = 1;

            Assert.IsFalse(p1.Equals(i));
        }
Exemplo n.º 4
0
        public void NotEqualWhenBothInstancesAreTransient()
        {
            ClassUsingGuidIdentity p1 = new ClassUsingGuidIdentity();
            ClassUsingGuidIdentity p2 = new ClassUsingGuidIdentity();

            Assert.IsFalse(p1.Equals(p2));
        }
Exemplo n.º 5
0
        public void NotEqualWhenSecondInstanceIsTransient()
        {
            ClassUsingGuidIdentity p1 = new ClassUsingGuidIdentity();
            ClassUsingGuidIdentity p2 = new ClassUsingGuidIdentity();

            SetInstanceFieldValue(p2, "_persistenceId", Guid.NewGuid());

            Assert.IsFalse(p1.Equals(p2));
        }
Exemplo n.º 6
0
        public void OperatorEqualOverloadTest()
        {
            ClassUsingGuidIdentity p1 = new ClassUsingGuidIdentity();
            ClassUsingGuidIdentity p2 = new ClassUsingGuidIdentity();

            Assert.IsFalse(p1.Equals(p2));

            Assert.IsFalse(p1 == p2);
            Assert.IsTrue(p1 != p2);
        }
Exemplo n.º 7
0
        public void EqualWhenInstancesHaveSameIdentityValue()
        {
            ClassUsingGuidIdentity p1 = new ClassUsingGuidIdentity();
            ClassUsingGuidIdentity p2 = new ClassUsingGuidIdentity();

            Guid g = Guid.NewGuid();

            SetInstanceFieldValue(p1, "_persistenceId", g);
            SetInstanceFieldValue(p2, "_persistenceId", g);

            Assert.IsTrue(p1.Equals(p2));
        }