public void AddAndRemoveLists() { _source1.AddRange(Enumerable.Range(1, 5)); _source2.AddRange(Enumerable.Range(6, 5)); _source3.AddRange(Enumerable.Range(1, 5)); _source.Add(_source1.Connect()); _source.Add(_source2.Connect()); _source.Add(_source3.Connect()); var result = Enumerable.Range(6, 5); Assert.AreEqual(5, _results.Data.Count); CollectionAssert.AreEquivalent(result, _results.Data.Items); _source.RemoveAt(0); result = Enumerable.Range(1, 5).Union(Enumerable.Range(6, 5)); Assert.AreEqual(10, _results.Data.Count); CollectionAssert.AreEquivalent(result, _results.Data.Items); _source.Add(_source1.Connect()); result = Enumerable.Range(6, 5); Assert.AreEqual(5, _results.Data.Count); CollectionAssert.AreEquivalent(result, _results.Data.Items); }
public void AddAndRemoveLists() { _source1.AddRange(Enumerable.Range(1, 5)); _source2.AddRange(Enumerable.Range(6, 5)); _source3.AddRange(Enumerable.Range(1, 5)); _source.Add(_source1.Connect()); _source.Add(_source2.Connect()); _source.Add(_source3.Connect()); var result = Enumerable.Range(6, 5); _results.Data.Count.Should().Be(5); _results.Data.Items.ShouldAllBeEquivalentTo(result); _source.RemoveAt(0); result = Enumerable.Range(1, 5).Union(Enumerable.Range(6, 5)); _results.Data.Count.Should().Be(10); _results.Data.Items.ShouldAllBeEquivalentTo(result); _source.Add(_source1.Connect()); result = Enumerable.Range(6, 5); _results.Data.Count.Should().Be(5); _results.Data.Items.ShouldAllBeEquivalentTo(result); }
public void RemoveIsUnsubscribed() { _source.Add(new SubscribeableObject(1)); _source.RemoveAt(0); Assert.AreEqual(2, _results.Messages.Count, "Should be 2 updates"); Assert.AreEqual(0, _results.Data.Count, "Should be 0 items in the cache"); Assert.AreEqual(false, _results.Messages[1].First().Item.Current.IsSubscribed, "Should be be unsubscribed"); }
public void AddAndRemoveLists() { var items = _generator.Take(100).ToArray(); _source1.AddOrUpdate(items.Take(20)); _source2.AddOrUpdate(items.Skip(10).Take(10)); _source.Add(_source1.Connect()); _source.Add(_source2.Connect()); Assert.AreEqual(10, _results.Data.Count); CollectionAssert.AreEquivalent(items.Skip(10).Take(10), _results.Data.Items); _source.Add(_source3.Connect()); Assert.AreEqual(0, _results.Data.Count); _source.RemoveAt(2); Assert.AreEqual(10, _results.Data.Count); }
public void AddAndRemoveLists() { var items = _generator.Take(100).ToArray(); _source1.AddOrUpdate(items.Take(20)); _source2.AddOrUpdate(items.Skip(10).Take(10)); _source.Add(_source1.Connect()); _source.Add(_source2.Connect()); _results.Data.Count.Should().Be(10); _results.Data.Items.Should().BeEquivalentTo(items.Skip(10).Take(10)); _source.Add(_source3.Connect()); _results.Data.Count.Should().Be(0); _source.RemoveAt(2); _results.Data.Count.Should().Be(10); }
public void AddAndRemoveLists() { _source1.AddRange(Enumerable.Range(1, 5)); _source2.AddRange(Enumerable.Range(6, 5)); _source3.AddRange(Enumerable.Range(100, 5)); _source.Add(_source1.Connect()); _source.Add(_source2.Connect()); _source.Add(_source3.Connect()); var result = Enumerable.Range(1, 5); _results.Data.Count.Should().Be(5); _results.Data.Items.Should().BeEquivalentTo(result); _source2.Edit( innerList => { innerList.Clear(); innerList.AddRange(Enumerable.Range(3, 5)); }); result = Enumerable.Range(1, 2); _results.Data.Count.Should().Be(2); _results.Data.Items.Should().BeEquivalentTo(result); _source.RemoveAt(1); result = Enumerable.Range(1, 5); _results.Data.Count.Should().Be(5); _results.Data.Items.Should().BeEquivalentTo(result); _source.Add(_source2.Connect()); result = Enumerable.Range(1, 2); _results.Data.Count.Should().Be(2); _results.Data.Items.Should().BeEquivalentTo(result); //remove root except _source.RemoveAt(0); result = Enumerable.Range(100, 5); _results.Data.Count.Should().Be(5); _results.Data.Items.Should().BeEquivalentTo(result); }
public void AddAndRemoveLists() { _source1.AddRange(Enumerable.Range(1, 5)); _source2.AddRange(Enumerable.Range(6, 5)); _source3.AddRange(Enumerable.Range(100, 5)); _source.Add(_source1.Connect()); _source.Add(_source2.Connect()); _source.Add(_source3.Connect()); var result = Enumerable.Range(1, 5); Assert.AreEqual(5, _results.Data.Count); CollectionAssert.AreEquivalent(result, _results.Data.Items); _source2.Edit(innerList => { innerList.Clear(); innerList.AddRange(Enumerable.Range(3, 5)); }); result = Enumerable.Range(1, 2); Assert.AreEqual(2, _results.Data.Count); CollectionAssert.AreEquivalent(result, _results.Data.Items); _source.RemoveAt(1); result = Enumerable.Range(1, 5); Assert.AreEqual(5, _results.Data.Count); CollectionAssert.AreEquivalent(result, _results.Data.Items); _source.Add(_source2.Connect()); result = Enumerable.Range(1, 2); Assert.AreEqual(2, _results.Data.Count); CollectionAssert.AreEquivalent(result, _results.Data.Items); //remove root except _source.RemoveAt(0); result = Enumerable.Range(100, 5); Assert.AreEqual(5, _results.Data.Count); CollectionAssert.AreEquivalent(result, _results.Data.Items); }
public void RemoveBeforeShiftsPage() { var people = _generator.Take(100).ToArray(); _source.AddRange(people); _controller.Virtualise(new VirtualRequest(25, 25)); _source.RemoveAt(0); var expected = people.Skip(26).Take(25).ToArray(); CollectionAssert.AreEqual(expected, _results.Data.Items); var removedMessage = _results.Messages[2].ElementAt(0); var removedPerson = people.ElementAt(25); Assert.AreEqual(removedPerson, removedMessage.Item.Current); Assert.AreEqual(ListChangeReason.Remove, removedMessage.Reason); var addedMessage = _results.Messages[2].ElementAt(1); var addedPerson = people.ElementAt(50); Assert.AreEqual(addedPerson, addedMessage.Item.Current); Assert.AreEqual(ListChangeReason.Add, addedMessage.Reason); }
public void Remove() { var people = _generator.Take(100).ToList(); _source.AddRange(people); var toRemove = people.ElementAt(20); people.RemoveAt(20); _source.RemoveAt(20); Assert.AreEqual(99, _results.Data.Count, "Should be 99 people in the cache"); Assert.AreEqual(2, _results.Messages.Count, "Should be 2 update messages"); Assert.AreEqual(toRemove, _results.Messages[1].First().Item.Current, "Incorrect item removed"); var expectedResult = people.OrderBy(p => p, _comparer); var actualResult = _results.Data.Items; CollectionAssert.AreEquivalent(expectedResult, actualResult); }
public void RemoveBeforeShiftsPage() { var people = _generator.Take(100).ToArray(); _source.AddRange(people); _requestSubject.OnNext(new PageRequest(2, 25)); _source.RemoveAt(0); var expected = people.Skip(26).Take(25).ToArray(); _results.Data.Items.ShouldAllBeEquivalentTo(expected); var removedMessage = _results.Messages[2].ElementAt(0); var removedPerson = people.ElementAt(25); removedMessage.Item.Current.Should().Be(removedPerson); removedMessage.Reason.Should().Be(ListChangeReason.Remove); var addedMessage = _results.Messages[2].ElementAt(1); var addedPerson = people.ElementAt(50); addedMessage.Item.Current.Should().Be(addedPerson); addedMessage.Reason.Should().Be(ListChangeReason.Add); }
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 ForceError() { var person = _generator.Take(1).First(); _source.RemoveAt(1); }
public void ForceError() { var person = _generator.Take(1).First(); Assert.Throws <ArgumentOutOfRangeException>(() => _source.RemoveAt(1)); }
public void RemoveAt(int index) { _sourceList.RemoveAt(index); }