예제 #1
0
        public void Test2()
        {
            var initial = "Initial";
            var updated = "Updated";

            var classInstance = new AClass { Name = initial };
            var structInstance = new AStruct { Name = initial };

            DoSomeEvil(classInstance, updated);
            DoSomeEvil(structInstance, updated);

            Assert.AreEqual(updated, classInstance.Name);
            Assert.AreEqual(initial, structInstance.Name);
        }
예제 #2
0
        public void Test()
        {
            var initial = "Initial";
            var updated = "Updated";

            var classInstance = new AClass { Name = initial };
            var structInstance = new AStruct { Name = initial };

            var anotherClassInstance = (IInterface) classInstance;
            var anotherStructInstance = (IInterface) structInstance;

            anotherClassInstance.Name = updated;
            anotherStructInstance.Name = updated;

            Assert.AreEqual(initial, structInstance.Name);
        }
예제 #3
0
        public void AnotherValuePropagationExample()
        {
            var initial = "Initial";
            var updated = "Updated";

            var structInstance = new AStruct { Name = initial };
            var classInstance = new AClass
            {
                Name = initial,
                Value = structInstance
            };

            // update origins
            var anotherStructInstance = classInstance.Value;
            anotherStructInstance.Name = updated;
            classInstance.Value = anotherStructInstance;

            Assert.AreEqual(updated, classInstance.Value.Name);
        }
예제 #4
0
        public void ValuesPropertyUpdatesPerformDifferentlyAcrossInstancesTest()
        {
            var initial = "Initial";
            var updated = "Updated";

            var classInstance = new AClass {Name = initial};
            var structInstance = new AStruct {Name = initial};

            // first wave
            var enotherClassInstance = classInstance;
            var enotherStructInstance = structInstance;

            Assert.AreEqual(initial, enotherClassInstance.Name);
            Assert.AreEqual(initial, enotherStructInstance.Name);

            // update origins
            classInstance.Name = updated;
            structInstance.Name = updated;

            Assert.AreEqual(updated, enotherClassInstance.Name);

            Assert.AreEqual(initial, enotherStructInstance.Name);
            Assert.AreEqual(updated, structInstance.Name);
        }