Esempio n. 1
0
        public static void TestFindOrderedListIntDesc()
        {
            var list = new OrderedList <int>(false);

            Assert.AreEqual(0, list.Count(), "TestFindOrderedListIntAsc orderedList size must be 0, but not");
            list.Add(4);
            list.Add(3);
            list.Add(2);
            list.Add(1);
            Assert.AreEqual(4, list.Count(), "TestFindOrderedListIntAsc orderedList size must be 4, but not");

            var found = list.Find(3);

            Assert.AreEqual(3, found.value);
            Assert.AreEqual(4, found.prev.value);
            Assert.AreEqual(2, found.next.value);

            found = list.Find(4);
            Assert.AreEqual(4, found.value);
            Assert.AreEqual(3, found.next.value);
            Assert.IsNull(found.prev);

            found = list.Find(1);
            Assert.AreEqual(1, found.value);
            Assert.AreEqual(2, found.prev.value);
            Assert.IsNull(found.next);
        }
        public void FindTest()
        {
            OrderedList <int> orderedListAsc = CreateOrderedList(
                true,
                0, 9, 8, 1, 2, 3, 7, 6, 5, 4);

            Assert.Null(orderedListAsc.Find(10));

            Node <int> node = orderedListAsc.Find(9);

            Assert.NotNull(node);

            Assert.Equal(9, node.value);
        }
        public void TestFindDes_2()
        {
            OrderedList <int> ord = new OrderedList <int>(false);

            ord.Add(5);
            ord.Add(4);
            ord.Add(2);
            ord.Add(1);

            Assert.AreEqual(1, ord.Find(1).value);
            Assert.AreEqual(2, ord.Find(2).value);
            Assert.AreEqual(null, ord.Find(3));
            Assert.AreEqual(4, ord.Find(4).value);
            Assert.AreEqual(5, ord.Find(5).value);
        }
Esempio n. 4
0
        public void Find_in_Empty_Desc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(false);

            Assert.IsNull(tList.Find(19));
            Assert.IsTrue(tList.Count() == 0);
        }
        public void Setup_Parsers_InsertsExtensionBlockParsers()
        {
            // Arrange
            Mock <BlockParser> dummyGlobalBlockParser    = _mockRepository.Create <BlockParser>();
            Mock <BlockParser> dummyNonGlobalBlockParser = _mockRepository.Create <BlockParser>();

            dummyNonGlobalBlockParser.Object.OpeningCharacters = new char[] { 'a' }; // Arbitrary opening character, can't mock because OpeningCharacters isn't virtual
            var dummyMarkdownPipelineBuilder = new MarkdownPipelineBuilder();
            Mock <BlockExtension <Block> > mockTestSubject = CreateMockBlockExtension(null, dummyGlobalBlockParser.Object, dummyNonGlobalBlockParser.Object);

            mockTestSubject.CallBase = true;
            mockTestSubject.Protected().Setup("SetupParsers", dummyMarkdownPipelineBuilder);

            // Act
            mockTestSubject.Object.Setup(dummyMarkdownPipelineBuilder);

            // Assert
            OrderedList <BlockParser> blockParsers = dummyMarkdownPipelineBuilder.BlockParsers;

            Assert.Contains(dummyNonGlobalBlockParser.Object, blockParsers);
            Assert.Contains(dummyGlobalBlockParser.Object, blockParsers);
            ParagraphBlockParser paragraphBlockParser = blockParsers.Find <ParagraphBlockParser>();

            Assert.True(blockParsers.IndexOf(dummyGlobalBlockParser.Object) < blockParsers.IndexOf(paragraphBlockParser)); // Global parsers must be inserted before catch all ParagraphBlockParser
            _mockRepository.VerifyAll();
        }
        public void TestFindAsc_1()
        {
            OrderedList <int> ord = new OrderedList <int>(true);

            ord.Add(3);
            ord.Add(2);
            ord.Add(1);

            Assert.AreEqual(2, ord.Find(2).value);
        }
        public void TestFindAsc_5()
        {
            OrderedList <string> ord = new OrderedList <string>(true);

            ord.Add("Crab");
            ord.Add("Raccoon");
            ord.Add("Cat");
            ord.Add("Fat man");

            Assert.AreEqual("Cat", ord.Find("Cat").value);
        }
        public void TestFindAsc_3()
        {
            OrderedList <int> ord = new OrderedList <int>(true);

            ord.Add(5);
            ord.Add(4);
            ord.Add(2);
            ord.Add(1);

            Assert.AreEqual(null, ord.Find(3));
        }
        public void Test_Find_WhenNotFound()
        {
            var list = new OrderedList <int>(true);

            list.Add(1);
            list.Add(2);
            list.Add(3);
            var result = list.Find(4);

            Assert.AreEqual(null, result);
        }
        public void Test_Find_WhenFilledOut()
        {
            var list = new OrderedList <int>(true);

            list.Add(1);
            list.Add(2);
            list.Add(3);
            var result = list.Find(2);

            Assert.AreEqual(2, result.value);
        }
        public void TestFindDes_1()
        {
            OrderedList <int> ord = new OrderedList <int>(false);

            ord.Add(5);
            ord.Add(4);
            ord.Add(2);
            ord.Add(1);

            Assert.AreEqual(null, ord.Find(3));
        }
Esempio n. 12
0
        public void Find_if_Elem_Is_not_Exists_in_Desc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(false);

            tList.Add(12);
            tList.Add(48);
            tList.Add(35);
            tList.Add(-101);

            Node <int> actual = tList.Find(42);

            Assert.IsNull(actual);
        }
Esempio n. 13
0
        public void Find_if_Elem_Is_not_Exists_in_Asc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(true);

            tList.Add(2);
            tList.Add(3);
            tList.Add(9);
            tList.Add(0);

            Node <int> actual = tList.Find(42);

            Assert.IsNull(actual);
        }
Esempio n. 14
0
        public void Find_if_Elem_Is_Exists_in_Desc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(false);

            tList.Add(12);
            tList.Add(48);
            tList.Add(35);

            tList.Add(-101);

            int expectedFoundValue = -101;
            int actualFoundValue   = tList.Find(-101).value;

            Assert.AreEqual(expectedFoundValue, actualFoundValue);
        }
Esempio n. 15
0
        public void Find_if_Elem_Is_Exists_in_Asc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(true);

            tList.Add(2);
            tList.Add(3);
            tList.Add(9);

            tList.Add(0);

            int expectedFoundValue = 3;
            int actualFoundValue   = tList.Find(3).value;

            Assert.AreEqual(expectedFoundValue, actualFoundValue);
        }
Esempio n. 16
0
        public void Delete_if_Elem_Is_Not_Exists_in_Asc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(true);

            tList.Add(12);
            tList.Add(48);
            tList.Add(35);
            tList.Add(-101);

            tList.Delete(42);
            Node <int> actualFoundValue = tList.Find(42);
            int        expectedSize     = 4;
            int        actualSize       = tList.Count();

            Assert.IsNull(actualFoundValue);
            Assert.AreEqual(expectedSize, actualSize);
        }
Esempio n. 17
0
        public void Delete_if_Elem_Is_Not_Exists_in_Desc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(false);

            tList.Add(122);
            tList.Add(7);
            tList.Add(21);
            tList.Add(7);
            tList.Add(0);

            tList.Delete(42);
            Node <int> actualFoundValue = tList.Find(42);

            int expectedSize = 5;
            int actualSize   = tList.Count();

            Assert.IsNull(actualFoundValue);
            Assert.AreEqual(expectedSize, actualSize);
        }
        public void TestDeleteIntegerAsc_4()
        {
            OrderedList <int> ord = new OrderedList <int>(true);

            ord.Add(3);
            ord.Add(2);
            ord.Add(1);

            ord.Delete(1);
            ord.Delete(2);
            ord.Delete(3);

            Assert.AreEqual(null, ord.tail);
            Assert.AreEqual(null, ord.tail);

            Node <int> node = ord.Find(1);

            Assert.AreEqual(null, node);
        }
Esempio n. 19
0
        public void Delete_if_Elem_Is_Exists_in_Desc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(false);

            tList.Add(12);
            tList.Add(48);
            tList.Add(35);
            tList.Add(-101);

            tList.Delete(12);

            Node <int> actualFoundValue = tList.Find(12);

            int expectedSize = 3;
            int actualSize   = tList.Count();

            Assert.IsNull(actualFoundValue);
            Assert.AreEqual(expectedSize, actualSize);
            Assert.IsTrue(tList.head.next.next.value == -101);
            Assert.IsTrue(tList.tail.prev.value == 35);
        }