public void Result_is_updated_after_Remove()
        {
            var subject = new ObservableCollection <int>(new [] { 0, 1, 2, 1, 2, 0, 2, 7 });
            var result  = subject.ToQueryable().Distinct().ToObservable();

            Assert.IsInstanceOfType(result, typeof(IQueryableObservableCollection <int>));

            subject.Remove(0);
            EnumerableAssert.AreEqual(result, 1, 2, 0, 7);

            subject.Remove(0);
            EnumerableAssert.AreEqual(result, 1, 2, 7);

            subject.Remove(7);
            EnumerableAssert.AreEqual(result, 1, 2);
        }
        public void Switches_to_new_observable()
        {
            var subject1 = new ObservableCollection <int>(new[] { 11, 12, 13, 14, 15, 16 });
            var subject2 = new ObservableCollection <int>(new[] { 13, 14, 15, 16, 17, 18 });

            var observer = new ObserverCollection <int>();

            observer.Observe(subject1);
            EnumerableAssert.AreEqual(subject1, observer);

            subject1.Insert(3, 77);
            EnumerableAssert.AreEqual(subject1, observer);

            observer.Observe(subject2);
            EnumerableAssert.AreEqual(subject2, observer);

            subject2.Insert(3, 77);
            EnumerableAssert.AreEqual(subject2, observer);
        }
        public void Result_is_updated_after_Replace()
        {
            var subject = new ObservableCollection <int>(new [] { 10, 11, 12, 11, 12, 10, 12, 17 });
            var result  = subject.ToQueryable().Distinct().ToObservable();

            Assert.IsInstanceOfType(result, typeof(IQueryableObservableCollection <int>));

            var events = new List <NotifyCollectionChangedEventArgs>();

            result.CollectionChanged += (s, e) => events.Add(e);

            subject[0] = 13;
            EnumerableAssert.AreEqual(result, 13, 11, 12, 10, 17);
            Assert.AreEqual(2, events.Count);

            subject[0] = 13;
            EnumerableAssert.AreEqual(result, 13, 11, 12, 10, 17);
            Assert.AreEqual(2, events.Count);

            subject[1] = 12;
            EnumerableAssert.AreEqual(result, 13, 12, 11, 10, 17);
            Assert.AreEqual(3, events.Count);
        }