예제 #1
0
        public void TestMethodBidirectRing2()
        {
            BidirectionalRingList <Organization> organizations = new BidirectionalRingList <Organization>();

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

            var expectedList = new BidirectionalRingList <Organization>(organizations);

            bool expected = expectedList.Contains(new Organization("Организация1", "Город1", 103));
            bool actual   = organizations.Contains(new Organization("Организация1", "Город1", 103));

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void TestMethodBidirectRing1()
        {
            BidirectionalRingList <Organization> organizations = new BidirectionalRingList <Organization>();

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

            var expectedList = new BidirectionalRingList <Organization>();

            organizations.Delete();
            organizations.ShowForward();

            Assert.AreEqual(expectedList.Count, organizations.Count);
        }
예제 #3
0
        public void TestMethodBidirectRing6()
        {
            BidirectionalRingList <Organization> organizations = new BidirectionalRingList <Organization>();

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

            BidirectionalRingList <Organization> clone = new BidirectionalRingList <Organization>();

            clone = (BidirectionalRingList <Organization>)organizations.Clone();

            organizations.RemoveAt(0);
            organizations.RemoveAt(3);
            organizations.RemoveAt(100);
            organizations.RemoveAt(-24);
            clone.RemoveAt(0);
            clone.RemoveAt(3);

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

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


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


            Assert.AreEqual(expected, actual);
        }
예제 #4
0
        public void TestMethodBidirectRing5()
        {
            BidirectionalRingList <Organization> organizations = new BidirectionalRingList <Organization>(4);

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

            BidirectionalRingList <Organization> expectedList = new BidirectionalRingList <Organization>(4);

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

            organizations.ShowForward();

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

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


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


            Assert.AreEqual(expected, actual);
        }
예제 #5
0
        public void TestMethodBidirectRing4()
        {
            BidirectionalRingList <Organization> organizations = new BidirectionalRingList <Organization>();

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

            BidirectionalRingList <Organization> copy = new BidirectionalRingList <Organization>();

            copy = organizations.Copy();

            organizations.Remove(new Organization("Организация1", "Город1", 103));

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

            foreach (Organization org1 in organizations)
            {
                if (i == 0)
                {
                    actual = org1;
                }
            }

            i = 0;
            foreach (Organization org2 in copy)
            {
                if (i == 0)
                {
                    expected = org2;
                }
            }

            Assert.AreEqual(expected, actual);
        }