public void ChangeTracking_Retain_Protocol_Info_Test()
        {
            var nested = new SDataResource {
                { "Country", "Australia" }, { "City", "Melbourne" }
            };

            nested.Key  = "address1";
            nested.ETag = "aaa1";
            var resource = new SDataResource {
                { "FirstName", "Joe" }, { "Address", nested }
            };

            resource.Key          = "contact1";
            resource.ETag         = "ccc1";
            resource.XmlNamespace = "ns";
            resource.XmlLocalName = "contact";
            resource.AcceptChanges();
            resource["FirstName"] = "Joanne";
            nested["City"]        = "Sydney";
            var changes = (SDataResource)resource.GetChanges();

            Assert.That(changes, Is.Not.EqualTo(resource));
            Assert.That(changes.Key, Is.EqualTo("contact1"));
            Assert.That(changes.ETag, Is.EqualTo("ccc1"));
            Assert.That(changes.XmlNamespace, Is.EqualTo("ns"));
            Assert.That(changes.XmlLocalName, Is.EqualTo("contact"));
            changes = (SDataResource)changes["Address"];
            Assert.That(changes, Is.Not.EqualTo(nested));
            Assert.That(changes.Key, Is.EqualTo("address1"));
            Assert.That(changes.ETag, Is.EqualTo("aaa1"));
        }
 public void ChangeTracking_RejectChanges_Test()
 {
     var resource = new SDataResource {{"FirstName", "Joe"}, {"LastName", "Bloggs"}};
     resource.AcceptChanges();
     Assert.That(resource.IsChanged, Is.False);
     Assert.That(resource.GetChanges(), Is.Null);
     resource.Remove("LastName");
     resource["FirstName"] = "Jill";
     resource.Add("Age", 33);
     Assert.That(resource.IsChanged, Is.True);
     Assert.That(resource.GetChanges(), Is.Not.Null);
     resource.RejectChanges();
     Assert.That(resource.IsChanged, Is.False);
     Assert.That(resource.GetChanges(), Is.Null);
 }
        public void ChangeTracking_RejectChanges_Test()
        {
            var resource = new SDataResource {
                { "FirstName", "Joe" }, { "LastName", "Bloggs" }
            };

            resource.AcceptChanges();
            Assert.That(resource.IsChanged, Is.False);
            Assert.That(resource.GetChanges(), Is.Null);
            resource.Remove("LastName");
            resource["FirstName"] = "Jill";
            resource.Add("Age", 33);
            Assert.That(resource.IsChanged, Is.True);
            Assert.That(resource.GetChanges(), Is.Not.Null);
            resource.RejectChanges();
            Assert.That(resource.IsChanged, Is.False);
            Assert.That(resource.GetChanges(), Is.Null);
        }
        public void ChangeTracking_Test()
        {
            var resource = new SDataResource {
                { "FirstName", "Joe" }, { "LastName", "Bloggs" }
            };

            resource.AcceptChanges();
            Assert.That(resource.IsChanged, Is.False);
            Assert.That(resource.GetChanges(), Is.Null);
            resource["FirstName"] = "Jill";
            Assert.That(resource.IsChanged, Is.True);
            Assert.That(resource.GetChanges(), Is.EqualTo(new Dictionary <string, object> {
                { "FirstName", "Jill" }
            }));
            resource.Add("Age", 33);
            Assert.That(resource.IsChanged, Is.True);
            Assert.That(resource.GetChanges(), Is.EqualTo(new Dictionary <string, object> {
                { "FirstName", "Jill" }, { "Age", 33 }
            }));
        }
        public void ChangeTracking_Nested_Test()
        {
            var nested = new SDataResource {
                { "Country", "Australia" }, { "City", "Melbourne" }
            };
            var resource = new SDataResource {
                { "Address", nested }
            };

            resource.AcceptChanges();
            Assert.That(nested.IsChanged, Is.False);
            Assert.That(nested.GetChanges(), Is.Null);
            Assert.That(resource.IsChanged, Is.False);
            Assert.That(resource.GetChanges(), Is.Null);
            nested["City"] = "Sydney";
            Assert.That(nested.IsChanged, Is.True);
            Assert.That(nested.GetChanges(), Is.EqualTo(new Dictionary <string, object> {
                { "City", "Sydney" }
            }));
            Assert.That(resource.IsChanged, Is.True);
            var changes = (IDictionary <string, object>)resource.GetChanges();

            Assert.That(changes.Count, Is.EqualTo(1));
            Assert.That(changes["Address"], Is.EqualTo(new Dictionary <string, object> {
                { "City", "Sydney" }
            }));
            nested.Add("State", "VIC");
            Assert.That(nested.IsChanged, Is.True);
            Assert.That(nested.GetChanges(), Is.EqualTo(new Dictionary <string, object> {
                { "City", "Sydney" }, { "State", "VIC" }
            }));
            Assert.That(resource.IsChanged, Is.True);
            changes = (IDictionary <string, object>)resource.GetChanges();
            Assert.That(changes.Count, Is.EqualTo(1));
            Assert.That(changes["Address"], Is.EqualTo(new Dictionary <string, object> {
                { "City", "Sydney" }, { "State", "VIC" }
            }));
        }
 public void ChangeTracking_Nested_Test()
 {
     var nested = new SDataResource {{"Country", "Australia"}, {"City", "Melbourne"}};
     var resource = new SDataResource {{"Address", nested}};
     resource.AcceptChanges();
     Assert.That(nested.IsChanged, Is.False);
     Assert.That(nested.GetChanges(), Is.Null);
     Assert.That(resource.IsChanged, Is.False);
     Assert.That(resource.GetChanges(), Is.Null);
     nested["City"] = "Sydney";
     Assert.That(nested.IsChanged, Is.True);
     Assert.That(nested.GetChanges(), Is.EqualTo(new Dictionary<string, object> {{"City", "Sydney"}}));
     Assert.That(resource.IsChanged, Is.True);
     var changes = (IDictionary<string, object>) resource.GetChanges();
     Assert.That(changes.Count, Is.EqualTo(1));
     Assert.That(changes["Address"], Is.EqualTo(new Dictionary<string, object> {{"City", "Sydney"}}));
     nested.Add("State", "VIC");
     Assert.That(nested.IsChanged, Is.True);
     Assert.That(nested.GetChanges(), Is.EqualTo(new Dictionary<string, object> {{"City", "Sydney"}, {"State", "VIC"}}));
     Assert.That(resource.IsChanged, Is.True);
     changes = (IDictionary<string, object>) resource.GetChanges();
     Assert.That(changes.Count, Is.EqualTo(1));
     Assert.That(changes["Address"], Is.EqualTo(new Dictionary<string, object> {{"City", "Sydney"}, {"State", "VIC"}}));
 }
 public void ChangeTracking_Retain_Protocol_Info_Test()
 {
     var nested = new SDataResource {{"Country", "Australia"}, {"City", "Melbourne"}};
     nested.Key = "address1";
     nested.ETag = "aaa1";
     var resource = new SDataResource {{"FirstName", "Joe"}, {"Address", nested}};
     resource.Key = "contact1";
     resource.ETag = "ccc1";
     resource.XmlNamespace = "ns";
     resource.XmlLocalName = "contact";
     resource.AcceptChanges();
     resource["FirstName"] = "Joanne";
     nested["City"] = "Sydney";
     var changes = (SDataResource) resource.GetChanges();
     Assert.That(changes, Is.Not.EqualTo(resource));
     Assert.That(changes.Key, Is.EqualTo("contact1"));
     Assert.That(changes.ETag, Is.EqualTo("ccc1"));
     Assert.That(changes.XmlNamespace, Is.EqualTo("ns"));
     Assert.That(changes.XmlLocalName, Is.EqualTo("contact"));
     changes = (SDataResource) changes["Address"];
     Assert.That(changes, Is.Not.EqualTo(nested));
     Assert.That(changes.Key, Is.EqualTo("address1"));
     Assert.That(changes.ETag, Is.EqualTo("aaa1"));
 }
 public void ChangeTracking_Test()
 {
     var resource = new SDataResource {{"FirstName", "Joe"}, {"LastName", "Bloggs"}};
     resource.AcceptChanges();
     Assert.That(resource.IsChanged, Is.False);
     Assert.That(resource.GetChanges(), Is.Null);
     resource["FirstName"] = "Jill";
     Assert.That(resource.IsChanged, Is.True);
     Assert.That(resource.GetChanges(), Is.EqualTo(new Dictionary<string, object> {{"FirstName", "Jill"}}));
     resource.Add("Age", 33);
     Assert.That(resource.IsChanged, Is.True);
     Assert.That(resource.GetChanges(), Is.EqualTo(new Dictionary<string, object> {{"FirstName", "Jill"}, {"Age", 33}}));
 }