private void ValidateChanges(ExpectedChanges expectedChanges, PlanSnapshot.Changes actualChanges)
        {
            ValidateChanges(expectedChanges.Inserted, actualChanges.Insert);
            ValidateChanges(expectedChanges.Deleted, actualChanges.Delete);

            Assert.AreEqual(expectedChanges.Updates.Count, actualChanges.Update.Count);

            foreach (var update in expectedChanges.Updates.GroupBy(x => x.ObjectId))
            {
                var updateId       = update.Key;
                var expectedUpdate = update.ToArray();
                var actualUpdate   = actualChanges.Update.FirstOrDefault(x => x.Node.Id == updateId);

                Assert.NotNull(actualUpdate);
                Assert.AreEqual(expectedUpdate.Length, actualUpdate.ChangedProperties.Count);

                foreach (var propUpdate in expectedUpdate)
                {
                    var name       = propUpdate.PropertyName;
                    var actualProp = actualUpdate.ChangedProperties.FirstOrDefault(x => x.Name == name);

                    Assert.NotNull(actualProp);
                    Assert.AreEqual(propUpdate.Value, actualProp.GetValue(actualUpdate.Node));
                }
            }
        }
Beispiel #2
0
        public void Update(PlanSnapshot.Changes changes)
        {
            foreach (var change in changes.Delete)
            {
                _storage.Remove(change.Id);
            }

            foreach (var change in changes.Insert)
            {
                _storage.Add(change.Id, change);
            }

            foreach (var changedObject in changes.Update)
            {
                var obj = _storage[changedObject.Node.Id];
                foreach (var prop in changedObject.ChangedProperties)
                {
                    prop.SetValue(obj, prop.GetValue(changedObject.Node));
                }
            }
        }
 public void Update(PlanSnapshot.Changes changes)
 {
     SubmittedChanges = changes;
 }