public void GetChangeSet_ThrowWhenPathNull() { var subject = new ChangeContainerValue("Initial Value"); subject.CurrentValue = "new value"; Assert.Throws <ArgumentNullException>(() => subject.GetChangeSet(null)); }
public void GetChangeSet_NullWhenNoChanges() { var subject = new ChangeContainerValue("Initial Value"); Assert.False(subject.HasChanges); var changes = subject.GetChangeSet(ChangePath.Empty, commit: true); Assert.Null(changes); }
public void GetChangeSet_CommitFalseKeepsChanges() { var subject = new ChangeContainerValue("Initial Value"); subject.CurrentValue = "New Value"; Assert.True(subject.HasChanges); var changes = subject.GetChangeSet(ChangePath.Empty); Assert.True(subject.HasChanges); }
public void GetChangeSet_CommitTrueCommitsChanges() { var expectedNewValue = "New Value"; var subject = new ChangeContainerValue("Initial Value"); subject.CurrentValue = expectedNewValue; Assert.True(subject.HasChanges); var changes = subject.GetChangeSet(ChangePath.Empty, commit: true); Assert.False(subject.HasChanges); Assert.Equal(expectedNewValue, subject.CurrentValue); }
public void GetChangeSet_GeneratesCorrectChangeSetForITracksChanges() { var path = ChangePath.Create("Key"); var expectedPath = path.AppendProperty(nameof(NestedObject.StringValue)); var nested = ChangeTrackingObject.CreateTrackable <NestedObject>(); var subject = new ChangeContainerValue(nested); nested.StringValue = "My new value;"; var changes = subject.GetChangeSet(path); Assert.Single(changes); Assert.True(changes.ContainsKey(expectedPath)); }
public void GetChangeSet_GeneratesCorrectChangeSet() { var expectedOldValue = "Initial Value"; var expectedNewValue = "New Value"; var expectedPath = ChangePath.Create("Key"); var subject = new ChangeContainerValue(expectedOldValue); subject.CurrentValue = expectedNewValue; var changes = subject.GetChangeSet(expectedPath); Assert.Single(changes); Assert.True(changes.ContainsKey(expectedPath)); Assert.Single(changes[expectedPath]); Assert.Equal(ChangeAction.Update, changes[expectedPath][0].Action); Assert.Equal(expectedOldValue, changes[expectedPath][0].OldValue); Assert.Equal(expectedNewValue, changes[expectedPath][0].NewValue); }