public void AddedObservableShouldWork() { var a = new CompositeSourceList <int>(); var b = new CompositeSourceList <int>(); var c = a.Concat(b); var addedResult = new List <IReadOnlyCollection <int> >(); var removedResult = new List <IReadOnlyCollection <int> >(); c.AddedToSetObservable().Subscribe(added => addedResult.Add(added)); c.RemovedFromSetObservable().Subscribe(removed => removedResult.Add(removed)); a.AddRange(new [] { 1, 2 }); b.AddRange(new [] { 8, 2 }); b.Remove(8); a.Remove(2); // Doesn't cause a remove event as 2 belongs to both sources a.Remove(1); addedResult[0].Should().BeEquivalentTo(1, 2); addedResult[1].Should().BeEquivalentTo(8); removedResult[0].Should().BeEquivalentTo(8); removedResult[1].Should().BeEquivalentTo(1); }
public void DynamicWhereShouldWork() { var a = new CompositeSourceList <int>(); var b = new CompositeSourceList <int>(); var filter = new BehaviorSubject <Func <int, bool> >(v => v > 5); var c = a.Concat(b).Where(filter); using (var r = c.Subscribe()) { r.Items.Count.Should().Be(0); a.AddRange(new List <int> { 1, 2, 3 }); r.Items.Should().BeEquivalentTo(); b.AddRange(new List <int> { 5, 6, 7 }); r.Items.Should().BeEquivalentTo(6, 7); } filter.OnNext(v => true); using (var r = c.Subscribe()) { r.Items.Should().BeEquivalentTo(1, 2, 3, 5, 6, 7); } }
public void AddedObservableShouldWork() { var a = new CompositeSourceList<int>(); var b = new CompositeSourceList<int>(); var c = a.Concat(b); var addedResult = new List<IReadOnlyCollection<int>>(); var removedResult = new List<IReadOnlyCollection<int>>(); c.AddedToSetObservable().Subscribe(added => addedResult.Add(added)); c.RemovedFromSetObservable().Subscribe(removed => removedResult.Add(removed)); a.AddRange(new [] {1,2}); b.AddRange(new [] {8,2}); b.Remove(8); a.Remove(2); // Doesn't cause a remove event as 2 belongs to both sources a.Remove(1); addedResult[0].Should().BeEquivalentTo(1, 2); addedResult[1].Should().BeEquivalentTo(8); removedResult[0].Should().BeEquivalentTo(8); removedResult[1].Should().BeEquivalentTo(1); }
public void ShouldWork() { var source0 = new CompositeSourceList <int>(); var source1 = new CompositeSourceList <int>(); var target = source0.Concat(source1); using (var observableCollection = target.CreateObservableCollection(EqualityComparer <int> .Default)) { observableCollection.Count.Should().Be(0); source0.Add(0); source1.Add(5); observableCollection.Should().Equal(0, 5); source0.Add(1); source1.Add(6); observableCollection.Should().Equal(0, 1, 5, 6); source0.Remove(1); observableCollection.Should().Equal(0, 5, 6); source1.Remove(5); observableCollection.Should().Equal(0, 6); source0.ReplaceAt(0, 10); observableCollection.Should().Equal(10, 6); } }
public void ShouldWork() { var source0 = new CompositeSourceList<int>(); var source1 = new CompositeSourceList<int>(); var target = source0.Concat(source1); using (var observableCollection = target.CreateObservableCollection(EqualityComparer<int>.Default)) { observableCollection.Count.Should().Be(0); source0.Add(0); source1.Add(5); observableCollection.Should().Equal(0, 5); source0.Add(1); source1.Add(6); observableCollection.Should().Equal(0, 1, 5, 6); source0.Remove(1); observableCollection.Should().Equal(0, 5, 6); source1.Remove(5); observableCollection.Should().Equal(0, 6); source0.ReplaceAt(0, 10); observableCollection.Should().Equal(10, 6); } }
public void BindingShouldWork() { var a = new CompositeSourceList <int>(); var b = new CompositeSourceList <int>(); var c = new CompositeSourceList <int>(); var d = b.Concat(c); d.Bind(a); }
public void WhereShouldWork() { var a = new CompositeSourceList <int>(); var b = new CompositeSourceList <int>(); var c = a.Concat(b).Where(v => v > 5); using (var r = c.Subscribe()) { r.Items.Count.Should().Be(0); a.AddRange(new List <int> { 1, 2, 3 }); r.Items.Should().BeEquivalentTo(); b.AddRange(new List <int> { 5, 6, 7 }); r.Items.Should().BeEquivalentTo(6, 7); a.Source = ImmutableList <int> .Empty; r.Items.Should().BeEquivalentTo(6, 7); } }
public void ShouldBeAbleToConcatLists() { var a = new CompositeSourceList <int>(); var b = new CompositeSourceList <int>(); var c = a.Concat(b); using (var r = c.Subscribe()) { r.Items.Count.Should().Be(0); a.AddRange(new List <int> { 1, 2, 3 }); r.Items.Should().BeEquivalentTo(1, 2, 3); b.AddRange(new List <int> { 5, 6, 7 }); r.Items.Should().BeEquivalentTo(1, 2, 3, 5, 6, 7); a.Source = ImmutableList <int> .Empty; r.Items.Should().BeEquivalentTo(5, 6, 7); } }
public void ManuallyNesting() { var a = new CompositeSourceList <int>(); var b = new CompositeSourceList <int>(); var c = new CompositeSourceList <int>(); var x = a.Concat(b); var y = x.Concat(c); using (var s = y.Subscribe()) { s.Items.Should().BeEmpty(); a.Source = a.Source.Add(1); s.Items.ShouldBeEquivalentTo(new[] { 1 }); b.Source = b.Source.Add(1); s.Items.Should().BeEquivalentTo(new[] { 1, 1 }); b.Source = b.Source.Add(3); s.Items.Should().BeEquivalentTo(new[] { 1, 1, 3 }); c.Source = c.Source.AddRange(new [] { 5, 6, 8 }); s.Items.Should().BeEquivalentTo(new[] { 1, 1, 3, 5, 6, 8 }); } }
public void ShouldWorkWithRangeOperators() { var source0 = new CompositeSourceList<int>(); var source1 = new CompositeSourceList<int>(); var target = source0.Concat(source1); using (var observableCollection = target.CreateObservableCollection(EqualityComparer<int>.Default)) { observableCollection.Count.Should().Be(0); source0.AddRange(new [] {0,1,2}); observableCollection.Should().Equal(0, 1,2); source0.Add(1); source1.Add(6); observableCollection.Should().Equal(0, 1, 2, 1, 6); source1.AddRange(new [] {3,4,5}); observableCollection.Should().Equal(0, 1, 2, 1, 6, 3, 4, 5); source0.InsertRangeAt(1, new [] {6,7}); observableCollection.Should().Equal(0, 6, 7, 1, 2, 1, 6, 3, 4, 5); source1.InsertRangeAt(1, new [] {6,7}); observableCollection.Should().Equal(0, 6, 7, 1, 2, 1, 6, 6, 7, 3, 4, 5); source0.Source.Should().Equal(0, 6, 7, 1, 2,1); source0.Replace(1,99); observableCollection.Should().Equal(0, 6, 7, 99, 2, 1, 6, 6, 7, 3, 4, 5); } }
public void WhereShouldWork() { var a = new CompositeSourceList<int>(); var b = new CompositeSourceList<int>(); var c = a.Concat(b).Where(v=>v>5); using (var r = c.Subscribe()) { r.Items.Count.Should().Be(0); a.AddRange(new List<int> {1,2,3}); r.Items.Should().BeEquivalentTo(); b.AddRange(new List<int> {5,6,7}); r.Items.Should().BeEquivalentTo(6,7); a.Source = ImmutableList<int>.Empty; r.Items.Should().BeEquivalentTo(6,7); } }
public void ShouldBeAbleToConcatLists() { var a = new CompositeSourceList<int>(); var b = new CompositeSourceList<int>(); var c = a.Concat(b); using (var r = c.Subscribe()) { r.Items.Count.Should().Be(0); a.AddRange(new List<int> {1,2,3}); r.Items.Should().BeEquivalentTo(1, 2, 3); b.AddRange(new List<int> {5,6,7}); r.Items.Should().BeEquivalentTo(1, 2, 3,5,6,7); a.Source = ImmutableList<int>.Empty; r.Items.Should().BeEquivalentTo(5,6,7); } }
public void ManuallyNesting() { var a = new CompositeSourceList<int>(); var b = new CompositeSourceList<int>(); var c = new CompositeSourceList<int>(); var x = a.Concat(b); var y = x.Concat(c); using (var s = y.Subscribe()) { s.Items.Should().BeEmpty(); a.Source=a.Source.Add(1); s.Items.ShouldBeEquivalentTo(new[]{1}); b.Source=b.Source.Add(1); s.Items.Should().BeEquivalentTo(new[]{1,1}); b.Source=b.Source.Add(3); s.Items.Should().BeEquivalentTo(new[]{1,1,3}); c.Source=c.Source.AddRange(new [] {5,6,8}); s.Items.Should().BeEquivalentTo(new[]{1,1,3,5,6,8}); } }
public void DynamicWhereShouldWork() { var a = new CompositeSourceList<int>(); var b = new CompositeSourceList<int>(); var filter = new BehaviorSubject<Func<int,bool>>(v=>v>5); var c = a.Concat(b).Where(filter); using (var r = c.Subscribe()) { r.Items.Count.Should().Be(0); a.AddRange(new List<int> {1,2,3}); r.Items.Should().BeEquivalentTo(); b.AddRange(new List<int> {5,6,7}); r.Items.Should().BeEquivalentTo(6,7); } filter.OnNext(v=>true); using (var r = c.Subscribe()) { r.Items.Should().BeEquivalentTo(1, 2, 3, 5, 6, 7); } }
public void BindingShouldWork() { var a = new CompositeSourceList<int>(); var b = new CompositeSourceList<int>(); var c = new CompositeSourceList<int>(); var d = b.Concat(c); d.Bind(a); }