public void RoundTripIList_Int32()
        {
            var model = TypeModel.Create();

            model.Add(typeof(TypeWithLists), false).Add(4, "IListInt32Untyped", typeof(int), null);
            TypeWithLists obj = new TypeWithLists();

            obj.IListInt32Untyped = new ArrayList();
            obj.IListInt32Untyped.Add(123);
            obj.IListInt32Untyped.Add(456);

            TypeWithLists clone = (TypeWithLists)model.DeepClone(obj);

            Assert.NotNull(clone);
            Assert.NotNull(clone.IListInt32Untyped);
            Assert.True(obj.IListInt32Untyped.Cast <int>().SequenceEqual(clone.IListInt32Untyped.Cast <int>()));

            model.CompileInPlace();
            clone = (TypeWithLists)model.DeepClone(obj);
            Assert.NotNull(clone);
            Assert.NotNull(clone.IListInt32Untyped);
            Assert.True(obj.IListInt32Untyped.Cast <int>().SequenceEqual(clone.IListInt32Untyped.Cast <int>()));

            clone = (TypeWithLists)model.Compile().DeepClone(obj);
            Assert.NotNull(clone);
            Assert.NotNull(clone.IListInt32Untyped);
            Assert.True(obj.IListInt32Untyped.Cast <int>().SequenceEqual(clone.IListInt32Untyped.Cast <int>()));
        }
        public void RoundTripIList_String()
        {
            var model = TypeModel.Create();

            model.Add(typeof(TypeWithLists), false).Add(4, "IListStringUntyped", typeof(string), null);
            TypeWithLists obj = new TypeWithLists();

            obj.IListStringUntyped = new ArrayList();
            obj.IListStringUntyped.Add("abc");
            obj.IListStringUntyped.Add("def");

            TypeWithLists clone = (TypeWithLists)model.DeepClone(obj);

            Assert.NotNull(clone);
            Assert.NotNull(clone.IListStringUntyped);
            Assert.True(obj.IListStringUntyped.Cast <string>().SequenceEqual(clone.IListStringUntyped.Cast <string>()));

            model.CompileInPlace();
            clone = (TypeWithLists)model.DeepClone(obj);
            Assert.NotNull(clone);
            Assert.NotNull(clone.IListStringUntyped);
            Assert.True(obj.IListStringUntyped.Cast <string>().SequenceEqual(clone.IListStringUntyped.Cast <string>()));

            clone = (TypeWithLists)model.Compile().DeepClone(obj);
            Assert.NotNull(clone);
            Assert.NotNull(clone.IListStringUntyped);
            Assert.True(obj.IListStringUntyped.Cast <string>().SequenceEqual(clone.IListStringUntyped.Cast <string>()));
        }
        public void RoundTripTypedList_Int32()
        {
            var model = TypeModel.Create();

            model.Add(typeof(TypeWithLists), false).Add(1, "ListInt32");
            TypeWithLists obj = new TypeWithLists();

            obj.ListInt32 = new List <int>();
            obj.ListInt32.Add(123);
            obj.ListInt32.Add(456);

            TypeWithLists clone = (TypeWithLists)model.DeepClone(obj);

            Assert.NotNull(clone);
            Assert.NotNull(clone.ListInt32);
            Assert.True(obj.ListInt32.SequenceEqual(clone.ListInt32));

            model.CompileInPlace();
            clone = (TypeWithLists)model.DeepClone(obj);
            Assert.NotNull(clone);
            Assert.NotNull(clone.ListInt32);
            Assert.True(obj.ListInt32.SequenceEqual(clone.ListInt32));

            clone = (TypeWithLists)model.Compile().DeepClone(obj);
            Assert.NotNull(clone);
            Assert.NotNull(clone.ListInt32);
            Assert.True(obj.ListInt32.SequenceEqual(clone.ListInt32));
        }
Esempio n. 4
0
        public void RoundTripTypedIList_Int32()
        {
            var model = TypeModel.Create();

            model.Add(typeof(TypeWithLists), false).Add(2, "IListInt32Typed");
            TypeWithLists obj = new TypeWithLists();

            obj.IListInt32Typed = new List <int>();
            obj.IListInt32Typed.Add(123);
            obj.IListInt32Typed.Add(456);

            TypeWithLists clone = (TypeWithLists)model.DeepClone(obj);

            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListInt32Typed);
            Assert.IsTrue(obj.IListInt32Typed.SequenceEqual(clone.IListInt32Typed));

            model.CompileInPlace();
            clone = (TypeWithLists)model.DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListInt32Typed);
            Assert.IsTrue(obj.IListInt32Typed.SequenceEqual(clone.IListInt32Typed));

            clone = (TypeWithLists)model.Compile().DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListInt32Typed);
            Assert.IsTrue(obj.IListInt32Typed.SequenceEqual(clone.IListInt32Typed));
        }
        public void RoundTripTypedList_String()
        {
            var model = TypeModel.Create();

            model.Add(typeof(TypeWithLists), false).Add(1, "ListString");
            TypeWithLists obj = new TypeWithLists();

            obj.ListString = new List <string>();
            obj.ListString.Add("abc");
            obj.ListString.Add("def");

            TypeWithLists clone = (TypeWithLists)model.DeepClone(obj);

            Assert.NotNull(clone);
            Assert.NotNull(clone.ListString);
            Assert.True(obj.ListString.SequenceEqual(clone.ListString));

            model.CompileInPlace();
            clone = (TypeWithLists)model.DeepClone(obj);
            Assert.NotNull(clone);
            Assert.NotNull(clone.ListString);
            Assert.True(obj.ListString.SequenceEqual(clone.ListString));

            clone = (TypeWithLists)model.Compile().DeepClone(obj);
            Assert.NotNull(clone);
            Assert.NotNull(clone.ListString);
            Assert.True(obj.ListString.SequenceEqual(clone.ListString));
        }
Esempio n. 6
0
        public void RoundTripTypedIList_String()
        {
            var model = TypeModel.Create();

            model.Add(typeof(TypeWithLists), false).Add(2, "IListStringTyped");
            TypeWithLists obj = new TypeWithLists();

            obj.IListStringTyped = new List <string>();
            obj.IListStringTyped.Add("abc");
            obj.IListStringTyped.Add("def");

            TypeWithLists clone = (TypeWithLists)model.DeepClone(obj);

            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListStringTyped);
            Assert.IsTrue(obj.IListStringTyped.SequenceEqual(clone.IListStringTyped));

            model.CompileInPlace();
            clone = (TypeWithLists)model.DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListStringTyped);
            Assert.IsTrue(obj.IListStringTyped.SequenceEqual(clone.IListStringTyped));

            clone = (TypeWithLists)model.Compile().DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListStringTyped);
            Assert.IsTrue(obj.IListStringTyped.SequenceEqual(clone.IListStringTyped));
        }
        public void RoundTripTypedList_String()
        {
            var model = TypeModel.Create();
            model.Add(typeof(TypeWithLists), false).Add(1, "ListString");
            TypeWithLists obj = new TypeWithLists();
            obj.ListString = new List<string>();
            obj.ListString.Add("abc");
            obj.ListString.Add("def");

            TypeWithLists clone = (TypeWithLists)model.DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.ListString);
            Assert.IsTrue(obj.ListString.SequenceEqual(clone.ListString));

            model.CompileInPlace();
            clone = (TypeWithLists)model.DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.ListString);
            Assert.IsTrue(obj.ListString.SequenceEqual(clone.ListString));

            clone = (TypeWithLists)model.Compile().DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.ListString);
            Assert.IsTrue(obj.ListString.SequenceEqual(clone.ListString));
        }
        public void RoundTripIList_Int32()
        {
            var model = TypeModel.Create();
            model.Add(typeof(TypeWithLists), false).Add(4, "IListInt32Untyped", typeof(int), null);
            TypeWithLists obj = new TypeWithLists();
            obj.IListInt32Untyped = new ArrayList();
            obj.IListInt32Untyped.Add(123);
            obj.IListInt32Untyped.Add(456);

            TypeWithLists clone = (TypeWithLists)model.DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListInt32Untyped);
            Assert.IsTrue(obj.IListInt32Untyped.Cast<int>().SequenceEqual(clone.IListInt32Untyped.Cast<int>()));

            model.CompileInPlace();
            clone = (TypeWithLists)model.DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListInt32Untyped);
            Assert.IsTrue(obj.IListInt32Untyped.Cast<int>().SequenceEqual(clone.IListInt32Untyped.Cast<int>()));

            clone = (TypeWithLists)model.Compile().DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListInt32Untyped);
            Assert.IsTrue(obj.IListInt32Untyped.Cast<int>().SequenceEqual(clone.IListInt32Untyped.Cast<int>()));
        }
        public void RoundTripTypedList_Int32()
        {
            var model = TypeModel.Create();
            model.Add(typeof(TypeWithLists), false).Add(1, "ListInt32");
            TypeWithLists obj = new TypeWithLists();
            obj.ListInt32 = new List<int>();
            obj.ListInt32.Add(123);
            obj.ListInt32.Add(456);

            TypeWithLists clone = (TypeWithLists)model.DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.ListInt32);
            Assert.IsTrue(obj.ListInt32.SequenceEqual(clone.ListInt32));

            model.CompileInPlace();
            clone = (TypeWithLists)model.DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.ListInt32);
            Assert.IsTrue(obj.ListInt32.SequenceEqual(clone.ListInt32));

            clone = (TypeWithLists)model.Compile().DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.ListInt32);
            Assert.IsTrue(obj.ListInt32.SequenceEqual(clone.ListInt32));
        }
        public void RoundTripIList_String()
        {
            var model = TypeModel.Create();
            model.Add(typeof(TypeWithLists), false).Add(4, "IListStringUntyped", typeof(string), null);
            TypeWithLists obj = new TypeWithLists();
            obj.IListStringUntyped = new ArrayList();
            obj.IListStringUntyped.Add("abc");
            obj.IListStringUntyped.Add("def");

            TypeWithLists clone = (TypeWithLists)model.DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListStringUntyped);
            Assert.IsTrue(obj.IListStringUntyped.Cast<string>().SequenceEqual(clone.IListStringUntyped.Cast<string>()));

            model.CompileInPlace();
            clone = (TypeWithLists)model.DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListStringUntyped);
            Assert.IsTrue(obj.IListStringUntyped.Cast<string>().SequenceEqual(clone.IListStringUntyped.Cast<string>()));

            clone = (TypeWithLists)model.Compile().DeepClone(obj);
            Assert.IsNotNull(clone);
            Assert.IsNotNull(clone.IListStringUntyped);
            Assert.IsTrue(obj.IListStringUntyped.Cast<string>().SequenceEqual(clone.IListStringUntyped.Cast<string>()));
        }