Пример #1
0
        public void TestMethodBidirect4()
        {
            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.RemoveAt(0);
            list.RemoveAt(1);
            list.RemoveAt(-5);
            list.RemoveAt(100);
            expectedList.RemoveAt(0);
            expectedList.RemoveAt(1);


            Assert.AreEqual(expectedList.Count, list.Count);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        public void TestMethodBidirect2()
        {
            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.RemoveAt(1);
            expectedList.RemoveAt(1);

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

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


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


            Assert.AreEqual(expected, actual);
        }