public void ShouldWork() { Fixture = ImmutableList <Data> .Empty; // Convert an INPC property to a subject ISubject <ImmutableList <Data> > s = this.PropertySubject(p => p.Fixture); var l = new ImmutableListToReactive <Data>(s); Fixture = Fixture.Add(new Data(10, 20)); l.ShouldAllBeEquivalentTo(Fixture); Fixture = Fixture.Add(new Data(11, 21)); l.ShouldAllBeEquivalentTo(Fixture); Fixture = Fixture.Add(new Data(12, 22)); l.ShouldAllBeEquivalentTo(Fixture); l.Add(new Data(33, 88)); l.ShouldAllBeEquivalentTo(Fixture); }
public void ShouldWork() { Fixture = ImmutableList <Data> .Empty; // Convert an INPC property to a subject ISubject <ImmutableList <Data> > s = this.PropertySubject(p => p.Fixture); var MutableList = new ImmutableListToReactive <Data>(s); var DerivedList = MutableList.CreateDerivedCollection(x => x); Fixture = Fixture.Add(new Data(10, 20)); DerivedList.ShouldAllBeEquivalentTo(Fixture); Fixture = Fixture.Add(new Data(11, 21)); DerivedList.ShouldAllBeEquivalentTo(Fixture); Fixture = Fixture.Add(new Data(12, 22)); MutableList.Count.Should().Be(3); DerivedList.ShouldAllBeEquivalentTo(Fixture); MutableList.ShouldAllBeEquivalentTo(Fixture); MutableList.Add(new Data(33, 88)); MutableList.Count.Should().Be(4); DerivedList.ShouldAllBeEquivalentTo(Fixture); MutableList.ShouldAllBeEquivalentTo(Fixture); MutableList[1] = new Data(99, 21); MutableList.Count.Should().Be(4); DerivedList.ShouldAllBeEquivalentTo(Fixture); MutableList.ShouldAllBeEquivalentTo(Fixture); var itemAtOne = MutableList[1]; MutableList.RemoveAt(1); MutableList.Should().NotContain(itemAtOne); MutableList.Count.Should().Be(3); DerivedList.ShouldAllBeEquivalentTo(Fixture); MutableList.ShouldAllBeEquivalentTo(Fixture); var i = new Data(78, 32); MutableList.Insert(0, i); DerivedList[0].Should().Be(i); MutableList.Count.Should().Be(4); DerivedList.ShouldAllBeEquivalentTo(Fixture); MutableList.ShouldAllBeEquivalentTo(Fixture); var j = new Data(18, 22); MutableList.Insert(3, j); DerivedList[3].Should().Be(j); MutableList.Count.Should().Be(5); DerivedList.ShouldAllBeEquivalentTo(Fixture); MutableList.ShouldAllBeEquivalentTo(Fixture); var k = new Data(18, 22); MutableList.Add(k); DerivedList[DerivedList.Count - 1].Should().Be(k); MutableList.Count.Should().Be(6); DerivedList.ShouldAllBeEquivalentTo(Fixture); MutableList.ShouldAllBeEquivalentTo(Fixture); MutableList.Remove(i); DerivedList[DerivedList.Count - 1].Should().Be(k); MutableList.Count.Should().Be(5); DerivedList.ShouldAllBeEquivalentTo(Fixture); MutableList.ShouldAllBeEquivalentTo(Fixture); }