Exemple #1
0
        public void DiffWithNonAtrributedPropertyChange()
        {
            DiffObject baseDiffObject = new DiffObject("Brian", "Developer", "111 Main Street", DateTime.Parse("1/1/1973"), "North");

            baseDiffObject.PhoneNumber = PhoneNumber.Parse("222-222-2222");

            DiffObject diffObject2 = new DiffObject("Brian", "Developer", "111 Main Street", DateTime.Parse("1/1/1973"), "North");

            diffObject2.PhoneNumber = PhoneNumber.Parse("222-222-2222");

            SubDiffObject diffObject3 = new SubDiffObject("Brian", "Developer", "111 Main Street", DateTime.Parse("1/1/1973"), "North");

            diffObject3.PhoneNumber = PhoneNumber.Parse("222-222-2222");

            diffObject2.Name     = "Brian Scott";
            diffObject2.Position = "Lead Developer";

            Diff <DiffObject> diff = baseDiffObject.CreateDiff(diffObject2);

            Assert.IsNotNull(diff);
            Assert.AreEqual(2, diff.Entries.Count);
            Assert.AreEqual("Name", diff.Entries[0].Name);
            Assert.AreEqual(baseDiffObject.Name, diff.Entries[0].BaselineValue);
            Assert.AreEqual(diffObject2.Name, diff.Entries[0].NewValue);
            Assert.AreEqual("Position", diff.Entries[1].Name);
            Assert.AreEqual(baseDiffObject.Position, diff.Entries[1].BaselineValue);
            Assert.AreEqual(diffObject2.Position, diff.Entries[1].NewValue);
        }
Exemple #2
0
        public void DiffableInterfaceOnStruct()
        {
            DiffObject baseDiffObject = new DiffObject("Brian", "Developer", "111 Main Street", DateTime.Parse("1/1/1973"), "North");

            baseDiffObject.PhoneNumber = PhoneNumber.Parse("222-222-2222");

            DiffObject diffObject2 = new DiffObject("Brian", "Developer", "111 Main Street", DateTime.Parse("1/1/1973"), "North");

            diffObject2.PhoneNumber = PhoneNumber.Parse("222-222-2222");

            SubDiffObject diffObject3 = new SubDiffObject("Brian", "Developer", "111 Main Street", DateTime.Parse("1/1/1973"), "North");

            diffObject3.PhoneNumber = PhoneNumber.Parse("222-222-2222");

            diffObject2.Address   = "150 Main Street";
            diffObject2.BirthDate = DateTime.Parse("1/1/1976");

            Diff <DiffObject> diff = baseDiffObject.CreateDiff(diffObject2);

            Assert.IsNotNull(diff);
            Assert.AreEqual(2, diff.Entries.Count);
            Assert.AreEqual("Address", diff.Entries[0].Name);
            Assert.AreEqual(baseDiffObject.Address, diff.Entries[0].BaselineValue);
            Assert.AreEqual(diffObject2.Address, diff.Entries[0].NewValue);
            Assert.AreEqual("BirthDate", diff.Entries[1].Name);
            Assert.AreEqual(baseDiffObject.BirthDate.ToString(), diff.Entries[1].BaselineValue);
            Assert.AreEqual(diffObject2.BirthDate.ToString(), diff.Entries[1].NewValue);
        }