Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction to RemoveRange/ReplaceRange unit tests #62

Merged
merged 4 commits into from
Mar 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions MvvmHelpers.UnitTests/ObservableRangeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,11 @@ public void ReplaceRange_on_empty_collection_should_NOT_raise_collection_changes
public void ReplaceRange_should_NOT_mutate_source()
{
var sourceData = new List<int>(new[] { 1, 2, 3 });
var collection = new ObservableRangeCollection<int>(new[] { 4, 5, 6 });
var collection = new ObservableRangeCollection<int>(new[] { 1, 2, 3, 4, 5, 6 });

collection.RemoveRange(sourceData);
collection.ReplaceRange(sourceData);

Assert.IsTrue(sourceData.Count == 3, "source data was mutated");
Assert.IsTrue(collection.Count == 3, "collection was mutated");
}

[TestMethod]
Expand Down Expand Up @@ -157,15 +156,37 @@ public void RemoveRangeEmpty()
}

[TestMethod]
public void RemoveRange_should_NOT_mutate_source()
public void RemoveRange_should_NOT_mutate_source_when_source_data_is_not_present()
{
var sourceData = new List<int>(new[] { 1, 2, 3 });
var collection = new ObservableRangeCollection<int>(new[] { 4, 5, 6 });

collection.RemoveRange(sourceData, NotifyCollectionChangedAction.Remove);

Assert.IsTrue(sourceData.Count == 3, "source data was mutated");
Assert.IsTrue(collection.Count == 3, "collection was mutated");
}

[TestMethod]
public void RemoveRange_should_NOT_mutate_source_when_source_data_is_present()
{
var sourceData = new List<int>(new[] { 1, 2, 3 });
var collection = new ObservableRangeCollection<int>(new[] { 1, 2, 3, 4, 5, 6 });

collection.RemoveRange(sourceData, NotifyCollectionChangedAction.Remove);

Assert.IsTrue(sourceData.Count == 3, "source data was mutated");
}

[TestMethod]
public void RemoveRange_should_NOT_mutate_collection_when_source_data_is_not_present()
{
var sourceData = new List<int>(new[] { 1, 2, 3 });
var collection = new ObservableRangeCollection<int>(new[] { 4, 5, 6, 7, 8, 9 });

collection.RemoveRange(sourceData, NotifyCollectionChangedAction.Remove);

// the collection should not be modified if the source items are not found
Assert.IsTrue(collection.Count == 6, "collection was mutated");
}
}
}