Ejemplo n.º 1
0
        public void WithListStringToWithListString()
        {
            var mapper = new MemberMapper();

              mapper.Options.Debug.DebugInformationEnabled = true;

              var source = new WithListofString { Foo = new List<string> { "test" } };

              var result = mapper.Map(source, new WithListofString());

              Assert.IsTrue(object.ReferenceEquals(source.Foo, result.Foo));

              var x = result;

              result.Foo = x.Foo;

              var newResult = mapper.Map(source, result);

              Assert.IsTrue(object.ReferenceEquals(result, newResult));
              Assert.IsTrue(object.ReferenceEquals(result.Foo, newResult.Foo));
              Assert.AreEqual(1, newResult.Foo.Count);

              var otherSource = new WithListofString { Foo = new List<string> { "test1" } };

              mapper.Map(otherSource, result);

              Assert.IsTrue(object.ReferenceEquals(result.Foo, newResult.Foo));
              Assert.AreEqual(2, result.Foo.Count);
        }
Ejemplo n.º 2
0
        public void WithListStringToWithListString()
        {
            var mapper = new MemberMapper();

            mapper.Options.Debug.DebugInformationEnabled = true;

            var source = new WithListofString {
                Foo = new List <string> {
                    "test"
                }
            };

            var result = mapper.Map(source, new WithListofString());

            Assert.IsTrue(object.ReferenceEquals(source.Foo, result.Foo));

            var x = result;

            result.Foo = x.Foo;

            var newResult = mapper.Map(source, result);

            Assert.IsTrue(object.ReferenceEquals(result, newResult));
            Assert.IsTrue(object.ReferenceEquals(result.Foo, newResult.Foo));
            Assert.AreEqual(1, newResult.Foo.Count);

            var otherSource = new WithListofString {
                Foo = new List <string> {
                    "test1"
                }
            };

            mapper.Map(otherSource, result);

            Assert.IsTrue(object.ReferenceEquals(result.Foo, newResult.Foo));
            Assert.AreEqual(2, result.Foo.Count);
        }