Inheritance: IComposite, IEditableObject
Beispiel #1
0
        public void ComplexMixinsCanMap()
        {
            var source = new Whole
            {
                Part = new Part { Name = "part1" },
                Parts = new List<Part> { new Part { Name = "part2" }, new Part { Name = "part3" } }
            };

            var destination = new Whole();
            source.MapTo(destination);
            Assert.IsTrue(source.EqualsByValue(destination));
        }
Beispiel #2
0
        public void ChangesCanBeCanceledWhenNulled()
        {
            var foo = new Whole
            {
                Part = new Part { Name = "part1" },
                Parts = new List<Part> { new Part { Name = "part2" }, new Part { Name = "part3" } }
            };

            var clone = foo.Clone(true);

            foo.BeginEdit();
            foo.Part = null;
            foo.Parts = null;
            Assert.IsFalse(foo.EqualsByValue(clone));
            foo.CancelEdit();

            Assert.IsTrue(foo.EqualsByValue(clone));
        }
Beispiel #3
0
        public void ComplexMixinsCanMapToOtherComplexMixins()
        {
            var source = new Whole
            {
                Part = new Part { Name = "part1" },
                Parts = new[] { new Part { Name = "part2" }, new Part { Name = "part3" } }
            };

            var destination = new VievModel();
            source.MapTo(destination, deep: true);
            Assert.AreNotSame(source.Part, destination.Part);
            Assert.AreEqual(source.Part.Name, destination.Part.Name);
            Assert.AreNotSame(source.Parts, destination.Parts);
            Assert.AreEqual(source.Parts.Count(), destination.Parts.Count());
            Assert.AreEqual(source.Parts.First().Name, destination.Parts.First().Name);
            Assert.AreEqual(source.Parts.Last().Name, destination.Parts.Last().Name);
        }