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 WhereManyShouldWork()
        {
            var a = new CompositeSourceList <CompositeSourceList <int> >();

            // Note that clist.Any(v => v>10) returns IObservable<bool>

            var b = from clist in a
                    where clist.Any(v => v > 10)
                    select clist;

            using (var s = b.Subscribe())
            {
                var x = new CompositeSourceList <int>();
                var y = new CompositeSourceList <int>();
                a.Add(x);
                a.Add(y);
                s.Items.Count.Should().Be(0);
                x.Add(9);
                s.Items.Count.Should().Be(0);
                x.Add(11);
                s.Items.Count.Should().Be(1);
                y.Add(12);
                s.Items.Count.Should().Be(2);
                x.Remove(11);
                s.Items.Count.Should().Be(1);
                x.Remove(9);
                s.Items.Count.Should().Be(1);
                y.Remove(12);
                s.Items.Count.Should().Be(0);
            }
        }
        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 WhereManyShouldWork()
        {
            var a = new CompositeSourceList<CompositeSourceList<int>>();

            // Note that clist.Any(v => v>10) returns IObservable<bool>

            var b = from clist in a
                    where clist.Any(v => v > 10)
                    select clist;

            using (var s = b.Subscribe())
            {
                var x = new CompositeSourceList<int>();
                var y = new CompositeSourceList<int>();
                a.Add(x);
                a.Add(y);
                s.Items.Count.Should().Be(0);
                x.Add(9);
                s.Items.Count.Should().Be(0);
                x.Add(11);
                s.Items.Count.Should().Be(1);
                y.Add(12);
                s.Items.Count.Should().Be(2);
                x.Remove(11);
                s.Items.Count.Should().Be(1);
                x.Remove(9);
                s.Items.Count.Should().Be(1);
                y.Remove(12);
                s.Items.Count.Should().Be(0);
            }
        }