Exemplo n.º 1
0
        public void Can_clone_DtoWithValueArray()
        {
            var expected = new DtoWithValueArray()
            {
                Values = new[] { 1, 2, 3 }
            };
            var clone = Incubator.Clone(expected);

            Assert.AreNotSame(expected, clone);
            Assert.AreNotSame(expected.Values, clone.Values);
            Assert.AreEqual(expected.Values, clone.Values);
        }
Exemplo n.º 2
0
        public void Can_ignore_properties()
        {
            var expected = new Simple()
            {
                Id = 42, Name = "Everything"
            };
            var clone = Incubator.Clone(expected, new[] { "Id" });

            Assert.AreNotSame(expected, clone);
            Assert.AreNotEqual(expected.Id, clone.Id);
            Assert.AreEqual(expected.Name, clone.Name);
        }
Exemplo n.º 3
0
        public void Can_clone_simple_dto()
        {
            var expected = new Simple()
            {
                Id = 42, Name = "Everything"
            };
            var clone = Incubator.Clone(expected);

            Assert.AreNotSame(expected, clone);
            Assert.AreEqual(expected.Id, clone.Id);
            Assert.AreEqual(expected.Name, clone.Name);
        }
Exemplo n.º 4
0
        public void Can_clone_DtoWithArrayList()
        {
            var expected = new DtoWithArrayList()
            {
                Values = new ArrayList()
            };

            expected.Values.Add("foo");
            var clone = Incubator.Clone(expected);

            Assert.AreNotSame(expected, clone);
            Assert.AreNotSame(expected.Values, clone.Values);
            Assert.AreEqual(expected.Values.ToArray(), clone.Values.ToArray());
        }
Exemplo n.º 5
0
        public void Can_clone_DtoWithValueCollection2()
        {
            var expected = new DtoWithValueCollection()
            {
                Values = new List <int>()
            };

            expected.Values.Add(1);
            expected.Values.Add(2);
            expected.Values.Add(3);
            var clone = Incubator.Clone(expected);

            Assert.AreNotSame(expected, clone);
            Assert.AreNotSame(expected.Values, clone.Values);
            Assert.AreEqual(expected.Values.ToArray(), clone.Values.ToArray());
        }
Exemplo n.º 6
0
        public void Can_clone_DtoWithObjectEnumerable()
        {
            var expected = new DtoWithObjectEnumerable()
            {
                Id       = 1,
                Children = new[] { new DtoWithObjectEnumerable()
                                   {
                                       Id = 2, Children = new[] { new DtoWithObjectEnumerable() }
                                   } }
            };
            var clone = Incubator.Clone(expected);

            Assert.AreNotSame(expected, clone);
            Assert.AreNotSame(expected.Children, clone.Children);
            Assert.AreEqual(expected.Children.First().Id, clone.Children.First().Id);
            Assert.AreEqual(expected.Children.First().Children.First().Id, clone.Children.First().Children.First().Id);
        }
Exemplo n.º 7
0
        public void Can_clone_DtoWithObjectArray()
        {
            var expected = new DtoWithObjectArray()
            {
                Id       = 1,
                Children = new[] { new DtoWithObjectArray()
                                   {
                                       Id = 2, Children = new[] { new DtoWithObjectArray() }
                                   } }
            };
            var clone = Incubator.Clone(expected);

            Assert.AreNotSame(expected, clone);
            Assert.AreNotSame(expected.Children, clone.Children);
            Assert.AreEqual(expected.Children[0].Id, clone.Children[0].Id);
            Assert.AreEqual(expected.Children[0].Children[0].Id, clone.Children[0].Children[0].Id);
        }
Exemplo n.º 8
0
        public void Can_clone_DtoWithDictionary()
        {
            var expected = new DtoWithDictionary()
            {
                Lookup = new Dictionary <string, Simple>()
                {
                    { "foo", new Simple()
                      {
                          Id = 1
                      } },
                    { "bar", new Simple()
                      {
                          Id = 2
                      } },
                }
            };
            var clone = Incubator.Clone(expected);

            Assert.AreNotSame(expected, clone);
            Assert.AreNotSame(expected.Lookup, clone.Lookup);
            Assert.AreEqual(expected.Lookup.Keys.OrderBy(x => x).ToArray(), clone.Lookup.Keys.OrderBy(x => x).ToArray());
            Assert.AreNotSame(expected.Lookup["foo"], clone.Lookup["foo"]);
            Assert.AreEqual(expected.Lookup["foo"].Id, clone.Lookup["foo"].Id);
        }