public void RemoveFilteredRange() { var people = Enumerable.Range(1, 10).Select(i => new Person("P" + i, i)).ToArray(); _source.AddRange(people); _results.Data.Count.Should().Be(0, "Should be 0 people in the cache"); _filter.OnNext(p => p.Age > 5); _results.Data.Count.Should().Be(5, "Should be 5 people in the cache"); _source.RemoveRange(5, 5); _results.Data.Count.Should().Be(0, "Should be 0 people in the cache"); }
public void RemoveRange() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); var child4 = new PersonWithRelations("Child4", 1); var child5 = new PersonWithRelations("Child5", 2); var anotherRelative1 = new PersonWithRelations("Another1", 2, new[] { child4, child5 }); var child6 = new PersonWithRelations("Child6", 1); var child7 = new PersonWithRelations("Child7", 2); var anotherRelative2 = new PersonWithRelations("Another2", 2, new[] { child6, child7 }); _source.AddRange(new[] { mother, anotherRelative1, anotherRelative2 }); _source.RemoveRange(0, 2); _results.Data.Count.Should().Be(2); _results.Data.Items.ShouldAllBeEquivalentTo(new[] { child6, child7 }); }
public void FormNewListFromChanges() { _source.Clear(); _source.AddRange(Enumerable.Range(1, 100)); // Collect preview messages about even numbers only var aggregator = _source.Preview(i => i % 2 == 0).AsAggregator(); _source.RemoveAt(10); _source.RemoveRange(10, 5); // Trigger changes _source.Add(1); _source.Add(2); Assert.True(aggregator.Messages.Count == 1); Assert.True(aggregator.Messages[0].Count == 1); Assert.True(aggregator.Messages[0].First().Item.Current == 2); Assert.True(aggregator.Messages[0].First().Reason == ListChangeReason.Add); // Cleanup aggregator.Dispose(); }
public void RemoveRange() { _source.AddRange(Enumerable.Range(1, 5)); _source.RemoveRange(1, 3); _results.Data.Items.ShouldAllBeEquivalentTo(new[] { 5, 1 }); }
public void RemoveRange() { _source.AddRange(Enumerable.Range(1, 5)); _source.RemoveRange(1, 3); CollectionAssert.AreEquivalent(new[] { 5, 1 }, _results.Data.Items); }