Exemple #1
0
        public void Test_Where_You_Expect_That_Reference_Objects_Will_Affect_Each_Other()
        {
            var myReferenceTypeClass = new ReferenceTypeClass();

            myReferenceTypeClass.Name = "pies";

            var myReferenceTypeClassCopy = myReferenceTypeClass;

            myReferenceTypeClassCopy.Name = "wilk";

            Assert.AreEqual(myReferenceTypeClass.Name, myReferenceTypeClassCopy.Name);

            var myValueTypeClass = new ValueTypesInClass();

            myValueTypeClass.X_Value = 1;
            myValueTypeClass.Y_Value = myValueTypeClass.X_Value;

            var copy = myValueTypeClass;

            copy.X_Value = 3;

            Assert.AreEqual(myValueTypeClass.X_Value, copy.X_Value);
            Assert.AreNotEqual(myValueTypeClass.X_Value, copy.Y_Value);

            var isItTrue = myValueTypeClass.Equals(copy);

            Assert.IsTrue(isItTrue);
        }
Exemple #2
0
        public void Test_Where_You_Expect_That_Value_Object_Will_Not_Affect_Each_Other()
        {
            var myValueTypeClass = new ValueTypesInClass();

            myValueTypeClass.X_Value = 1;
            myValueTypeClass.Y_Value = myValueTypeClass.X_Value;

            Assert.AreEqual(myValueTypeClass.X_Value, myValueTypeClass.Y_Value);

            myValueTypeClass.X_Value = 2;

            Assert.AreNotEqual(myValueTypeClass.X_Value, myValueTypeClass.Y_Value);
        }