Skip to content

Commit

Permalink
Merge pull request #62 from mjfreelancing/master
Browse files Browse the repository at this point in the history
Correction to RemoveRange/ReplaceRange unit tests
  • Loading branch information
jamesmontemagno authored Mar 3, 2020
2 parents b84ba09 + 9f82973 commit a68db31
Showing 1 changed file with 26 additions and 5 deletions.
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");
}
}
}

0 comments on commit a68db31

Please sign in to comment.