public void TestListOrderBy() { var l = new HashSet<int>().ToLiveSet(); var t = l.OrderByStatic(i => i).ToIndependent(); t.States().Take(1).Check( () => { }, state => { var s = state.Single(); Assert.IsTrue(s.Status == StateStatus.Connecting); Assert.IsTrue(s.Inner.SequenceEqual(new int[] { })); Assert.IsTrue(s.Delta == null); Assert.IsTrue(s.LastUpdated == 0); }); t.States().Skip(1).Take(1).Check( () => l.PublishInner.Add(20, 1000), state => { var s = state.Single(); Assert.IsTrue(s.Status == StateStatus.Connected); Assert.IsTrue(s.Inner.SequenceEqual(new[] { 20 })); Assert.IsTrue(s.Delta.IndexDeltas.SequenceEqual(new[] { new IndexNode<int> { Index = 0, DenseIndex = 0, Data = new ListIndexDelta<int> { InsertItems = new[] { 20 }, }, }, }, new IndexNodeComparer<int>())); Assert.IsTrue(s.LastUpdated == 1000); }); t.States().Skip(1).Take(1).Check( () => l.PublishInner.Add(10, 2000), state => { var s = state.Single(); Assert.IsTrue(s.Status == StateStatus.Connected); Assert.IsTrue(s.Inner.SequenceEqual(new[] { 10, 20 })); Assert.IsTrue(s.Delta.IndexDeltas.SequenceEqual(new[] { new IndexNode<int> { Index = 0, DenseIndex = 0, Data = new ListIndexDelta<int> { InsertItems = new[] { 10 }, }, }, }, new IndexNodeComparer<int>())); Assert.IsTrue(s.LastUpdated == 2000); }); t.States().Skip(1).Take(1).Check( () => l.PublishInner.Add(30, 3000), state => { var s = state.Single(); Assert.IsTrue(s.Status == StateStatus.Connected); Assert.IsTrue(s.Inner.SequenceEqual(new[] { 10, 20, 30 })); Assert.IsTrue(s.Delta.IndexDeltas.SequenceEqual(new[] { new IndexNode<int> { Index = 2, DenseIndex = 0, Data = new ListIndexDelta<int> { InsertItems = new[] { 30 }, }, }, }, new IndexNodeComparer<int>())); Assert.IsTrue(s.LastUpdated == 3000); }); t.States().Skip(1).Take(1).Check( () => l.PublishInner.Add(0, 4000), state => { var s = state.Single(); Assert.IsTrue(s.Status == StateStatus.Connected); Assert.IsTrue(s.Inner.SequenceEqual(new[] { 0, 10, 20, 30 })); Assert.IsTrue(s.Delta.IndexDeltas.SequenceEqual(new[] { new IndexNode<int> { Index = 0, DenseIndex = 0, Data = new ListIndexDelta<int> { InsertItems = new[] { 0 }, }, }, }, new IndexNodeComparer<int>())); Assert.IsTrue(s.LastUpdated == 4000); }); t.States().Skip(1).Take(1).Check( () => l.PublishInner.Add(15, 5000), state => { var s = state.Single(); Assert.IsTrue(s.Status == StateStatus.Connected); Assert.IsTrue(s.Inner.SequenceEqual(new[] { 0, 10, 15, 20, 30 })); Assert.IsTrue(s.Delta.IndexDeltas.SequenceEqual(new[] { new IndexNode<int> { Index = 2, DenseIndex = 0, Data = new ListIndexDelta<int> { InsertItems = new[] { 15 }, }, }, }, new IndexNodeComparer<int>())); Assert.IsTrue(s.LastUpdated == 5000); }); t.States().Skip(1).Take(1).Check( () => l.PublishInner.Remove(15, 6000), state => { var s = state.Single(); Assert.IsTrue(s.Status == StateStatus.Connected); Assert.IsTrue(s.Inner.SequenceEqual(new[] { 0, 10, 20, 30 })); Assert.IsTrue(s.Delta.IndexDeltas.SequenceEqual(new[] { new IndexNode<int> { Index = 2, DenseIndex = 0, Data = new ListIndexDelta<int> { DeleteItems = new[] { 15 }, }, }, }, new IndexNodeComparer<int>())); Assert.IsTrue(s.LastUpdated == 6000); }); t.States().Skip(1).Take(1).Check( () => l.PublishInner.Connect(new[] { 20, 10 }, 7000), state => { var s = state.Single(); Assert.IsTrue(s.Status == StateStatus.Reconnecting); Assert.IsTrue(s.Inner.SequenceEqual(new[] { 10, 20 })); Assert.IsTrue(s.Delta == null); Assert.IsTrue(s.LastUpdated == 7000); }); }