public void RemoveItemAfterSubscribing()
 {
     var source = new ObservableList<ObservableList<string>>();
     ImmutableList<string> result = ImmutableList<string>.Empty;
     source.ToLiveLinq()
         .SelectMany((list, _) => list.ToLiveLinq())
         .ToObservableEnumerable().Subscribe(value => result = value);
     source.Add(new ObservableList<string>());
     source.RemoveAt(0);
     result.Should().BeEmpty();
 }
 public void DisposeSubscription_ThenRemoveItem()
 {
     var source = new ObservableList<ObservableList<string>>();
     ImmutableList<string> result = ImmutableList<string>.Empty;
     var subscription = source.ToLiveLinq()
         .SelectMany((list, _) => list.ToLiveLinq())
         .ToObservableEnumerable().Subscribe(value => result = value);
     source.Add(new ObservableList<string>());
     source.Add(new ObservableList<string>());
     source[0].Add("a");
     source[1].Add("c");
     subscription.Dispose();
     source.RemoveAt(1);
     result.Should().ContainInOrder("a", "c");
 }
        public void WhereThenSelect()
        {
            var coll1 = new ObservableList<SelectObservableCollectionViewModel>();
            var result = coll1.ToLiveLinq().Where(nested => nested.Name.Select(val => val.Length > 2).Snapshot())
                .Select(nested => nested.Name.AsObservable()).ToReadOnlyObservableList();
            result.Count.Should().Be(0);

            coll1.Add(new SelectObservableCollectionViewModel(string.Empty));
            result.Count.Should().Be(0);

            coll1[0].Name.Value = "test";
            result.Count.Should().Be(1);
            result[0].Should().Be("test");

            coll1[0].Name.Value = "test2";
            result.Count.Should().Be(1);
            result[0].Should().Be("test2");

            coll1[0].Name.Value = "t";
            result.Count.Should().Be(0);
        }
 public void AddItemAfterSubscribing_AddSubItemsAfterSubscribing()
 {
     var source = new ObservableList<ObservableList<string>>();
     ImmutableList<string> result = ImmutableList<string>.Empty;
     source.ToLiveLinq()
         .SelectMany((list, _) => list.ToLiveLinq())
         .ToObservableEnumerable().Subscribe(value => result = value);
     source.Add(new ObservableList<string>());
     source.Add(new ObservableList<string>());
     source[0].Add("a");
     source[0].Add("b");
     source[1].Add("c");
     source[1].Add("d");
     result.Should().ContainInOrder("a", "b", "c", "d");
 }
 public void AddItemBeforeSubscribing_AddSubItemsBeforeSubscribing_RemoveSubItemsAfterSubscribing()
 {
     var source = new ObservableList<ObservableList<string>>();
     ImmutableList<string> result = ImmutableList<string>.Empty;
     source.Add(new ObservableList<string>());
     source.Add(new ObservableList<string>());
     source[0].Add("a");
     source[0].Add("b");
     source[1].Add("c");
     source[1].Add("d");
     source.ToLiveLinq()
         .SelectMany((list, _) => list.ToLiveLinq())
         .ToObservableEnumerable().Subscribe(value => result = value);
     source[0].Clear();
     source[1].Clear();
     result.Should().BeEmpty();
 }