Example #1
0
        public void DeepCopyTest()
        {
            var simple = new SimpleClass()
            {
                Primitive = 1, Str = "apollo ssc"
            };
            var complex = new ComplexClass {
                Reference = simple
            };
            var obj = new DeepClass {
                List = new List <ComplexClass> {
                    complex
                }
            };
            var copy = obj.Copy();

            Check.That(obj).IsNotEqualTo(copy);
            Check.That(obj.List).IsNotEqualTo(copy.List);
            Check.That(copy.List).HasSize(1);
            Check.That(obj.List[0]).IsNotEqualTo(copy.List[0]);
            Check.That(obj.List[0].Reference).IsNotEqualTo(copy.List[0].Reference);
            Check.That(obj.List[0].Reference.Str).IsEqualTo(copy.List[0].Reference.Str);
        }