示例#1
0
        public void TestMethodBidirect1()
        {
            var list = new BidirectionalList();

            list.AddToEnd(new Organization("Организация1", "Город1", 103));
            list.AddToEnd(new Organization("Организация2", "Город2", 500));
            list.AddToStart(new Organization("Организация3", "Город3", 303));

            var expectedList = new BidirectionalList();

            expectedList.AddToEnd(new Organization("Организация1", "Город1", 103));
            expectedList.AddToEnd(new Organization("Организация2", "Город2", 500));
            expectedList.AddToStart(new Organization("Организация3", "Город3", 303));


            list.TaskAddAt(2, new Organization("Организация4", "Город4", 125));
            expectedList.TaskAddAt(2, new Organization("Организация4", "Город4", 125));

            Organization actual   = null;
            Organization expected = null;
            int          i        = 0;

            foreach (Organization org1 in list)
            {
                if (i == 2)
                {
                    actual = org1;
                }
                i++;
            }


            i = 0;
            foreach (Organization org2 in expectedList)
            {
                if (i == 2)
                {
                    expected = org2;
                }
                i++;
            }


            list.ShowBackward();
            list.ShowForward();
            expectedList.ShowBackward();
            expectedList.ShowForward();

            Assert.AreEqual(expected, actual);
        }
示例#2
0
        public void TestMethodBidirect3()
        {
            var list = new BidirectionalList();

            list.AddToEnd(new Organization("Организация1", "Город1", 103));
            list.AddToEnd(new Organization("Организация2", "Город2", 503));
            list.AddToStart(new Organization("Организация3", "Город3", 303));

            var expectedList = new BidirectionalList();

            list.DeleteList();
            list.ShowBackward();
            list.ShowForward();

            Assert.AreEqual(expectedList.Count, list.Count);
        }