Ejemplo n.º 1
0
        public void Add_ToInsideOfList()
        {
            var itemstate = new List <TestItem>()
            {
                CreateItem(0),
                CreateItem(1),
                // "insert" here
                CreateItem(2),
                CreateItem(3)
            };
            var items    = CreateSource();
            var reprocct = 0;

            Dump("Before", itemstate);
            var reproc = ChartComponent.IncrementalAdd(itemstate.Count / 2, items, itemstate, CreateItem,
                                                       (rpc, istate) => {
                reprocct++;
                ResequenceAdd(rpc, istate);
            });

            Dump("After", itemstate);
            Assert.AreEqual(3, reproc.Count, "reproc.Count failed");
            Assert.AreEqual(7, itemstate.Count, "itemstate.Count failed");
            Assert.AreEqual(2, reprocct, "reprocct failed");
            Compare(itemstate);
            Compare(2, itemstate[2], items[0]);
            Compare(3, itemstate[3], items[1]);
            Compare(4, itemstate[4], items[2]);
        }
Ejemplo n.º 2
0
        public void Add_NullAddsNothing()
        {
            var itemstate = new List <TestItem>();
            var items     = CreateSource();
            var reprocct  = 0;

            Dump("Before", itemstate);
            var reproc = ChartComponent.IncrementalAdd(0, items, itemstate, (ix, dso) => null, (rpc, istate) => {
                reprocct++;
                ResequenceAdd(rpc, istate);
            });

            Dump("After", itemstate);
            Assert.AreEqual(0, reproc.Count, "reproc.Count failed");
            Assert.AreEqual(0, itemstate.Count, "itemstate.Count failed");
            Assert.AreEqual(0, reprocct, "reprocct failed");
        }
Ejemplo n.º 3
0
        public void Add_ToEmptyList()
        {
            var itemstate = new List <TestItem>();
            var items     = CreateSource();
            var reprocct  = 0;

            Dump("Before", itemstate);
            var reproc = ChartComponent.IncrementalAdd(0, items, itemstate, CreateItem, (rpc, istate) => {
                reprocct++;
                ResequenceAdd(rpc, istate);
            });

            Dump("After", itemstate);
            Assert.AreEqual(3, reproc.Count, "reproc.Count failed");
            Assert.AreEqual(3, itemstate.Count, "itemstate.Count failed");
            Assert.AreEqual(0, reprocct, "reprocct failed");
            Compare(itemstate);
            Compare(0, itemstate[0], items[0]);
            Compare(1, itemstate[1], items[1]);
            Compare(2, itemstate[2], items[2]);
        }