Example #1
0
        public void RemoveAndDisposeBefore(ushort offset, int n, int index)
        {
            var tree = new Carambolas.Net.Channel.Inbound.Node.Tree <Node>();

            for (int i = 0; i < n; ++i)
            {
                var seq = new Protocol.Ordinal((ushort)(offset + i));
                Assert.True(tree.TryAdd(new Node()
                {
                    SequenceNumber = seq
                }));
                Assert.False(tree.IsEmpty);
            }

            var keep = new Protocol.Ordinal((ushort)(offset + index));

            tree.RemoveAndDisposeBefore(keep);
            for (int i = 0; i < n; ++i)
            {
                var seq = new Protocol.Ordinal((ushort)(offset + i));
                if (seq < keep)
                {
                    Assert.False(tree.TryGet(seq, out Node node));
                }
                else
                {
                    Assert.True(tree.TryGet(seq, out Node node));
                }

                if (index >= n)
                {
                    Assert.True(tree.IsEmpty);
                }
            }
        }
Example #2
0
        public void RemoveAndDisposeBeforeSequenceNumberFromEmptyTree(ushort seq)
        {
            var tree = new Carambolas.Net.Channel.Inbound.Node.Tree <Node>();

            tree.RemoveAndDisposeBefore(new Protocol.Ordinal(seq));
        }