public void When_I_Compare_IDictionary_I_Get_Updated_Added_And_Removed_Values()
        {
            var comparer = Comparer.GetComparer<HasDictionary>();
            var oldModel = new HasDictionary
            {
                Names = new Dictionary<string, string>
                {
                    {"fr", "Salut"},
                    {"en", "Hi"}
                }
            };
            var newModel = new HasDictionary
            {
                Names = new Dictionary<string, string>
                {
                    {"en", "Hello"},
                    {"es", "Hola"}
                }
            };

            var changes = comparer(oldModel, newModel);
            Assert.AreEqual(changes.Count(), 3);
            Assert.IsNotNull(changes.Single(x => x.Name == "Names.fr" && (string)x.OldValue == "Salut"));
            Assert.IsNotNull(changes.Single(x => x.Name == "Names.es" && (string)x.NewValue == "Hola"));
            Assert.IsNotNull(changes.Single(x => x.Name == "Names.en" && (string)x.OldValue == "Hi" && (string)x.NewValue == "Hello"));
        }
Beispiel #2
0
        public void Compare_Object_With_Dictionary_Property()
        {
            var comparer = SutEngine.Get <HasDictionary>();
            var oldModel = new HasDictionary
            {
                Names = new Dictionary <string, string>
                {
                    { "fr", "Salut" },
                    { "en", "Hi" }
                }
            };
            var newModel = new HasDictionary
            {
                Names = new Dictionary <string, string>
                {
                    { "en", "Hello" },
                    { "es", "Hola" }
                }
            };

            var changes = comparer(oldModel, newModel);

            Assert.AreEqual(changes.Count(), 3);
            Assert.IsNotNull(changes.Single(x => x.Name == "Names.fr" && (string)x.OldValue == "Salut"));
            Assert.IsNotNull(changes.Single(x => x.Name == "Names.es" && (string)x.NewValue == "Hola"));
            Assert.IsNotNull(changes.Single(x => x.Name == "Names.en" && (string)x.OldValue == "Hi" && (string)x.NewValue == "Hello"));
        }
        public void Compare_Object_With_Dictionary_Property()
        {
            var comparer = SutEngine.Get<HasDictionary>();
            var oldModel = new HasDictionary
            {
                Names = new Dictionary<string, string>
                {
                    {"fr", "Salut"},
                    {"en", "Hi"}
                }
            };
            var newModel = new HasDictionary
            {
                Names = new Dictionary<string, string>
                {
                    {"en", "Hello"},
                    {"es", "Hola"}
                }
            };

            var changes = comparer(oldModel, newModel);
            Assert.AreEqual(changes.Count(), 3);
            Assert.IsNotNull(changes.Single(x => x.Name == "Names.fr" && (string)x.OldValue == "Salut"));
            Assert.IsNotNull(changes.Single(x => x.Name == "Names.es" && (string)x.NewValue == "Hola"));
            Assert.IsNotNull(changes.Single(x => x.Name == "Names.en" && (string)x.OldValue == "Hi" && (string)x.NewValue == "Hello"));
        }