Пример #1
0
        public void GivenContentFile_WhenGetEntryByPosition_ThenGetExpectedEntry()
        {
            // Arrange
            var lines = new[]
            {
                "    _  _     _  _  _  _  _ ",
                "  | _| _||_||_ |_   ||_||_|",
                "  ||_  _|  | _||_|  ||_| _|",
                "                           ",
                " _  _  _  _  _  _  _  _  _ ",
                "| || || || || || || || || |",
                "|_||_||_||_||_||_||_||_||_|",
                "                           ",
                "                           ",
                "  |  |  |  |  |  |  |  |  |",
                "  |  |  |  |  |  |  |  |  |",
                "                           ",
                " _  _  _  _  _  _  _  _  _ ",
                " _| _| _| _| _| _| _| _| _|",
                "|_ |_ |_ |_ |_ |_ |_ |_ |_ ",
                "                           ",
            };

            var numberRecognizerMock = new Mock <INumberRecognizer>();

            // Act
            var documentParser = new DocumentParser(numberRecognizerMock.Object);
            var entry          = documentParser.GetEntryByPosition(lines, 0).ToList();

            Assert.IsNotNull(entry, "entry should not be null");
            Assert.AreEqual(4, entry.Count, "4 lines should be returned");
            Assert.AreEqual(lines[0], entry[0]);
            Assert.AreEqual(lines[1], entry[1]);
            Assert.AreEqual(lines[2], entry[2]);

            entry = documentParser.GetEntryByPosition(lines, 1).ToList();
            Assert.IsNotNull(entry, "entry should not be null");
            Assert.AreEqual(4, entry.Count, "4 lines should be returned");
            Assert.AreEqual(lines[4], entry[0]);
            Assert.AreEqual(lines[5], entry[1]);
            Assert.AreEqual(lines[6], entry[2]);

            entry = documentParser.GetEntryByPosition(lines, 2).ToList();
            Assert.IsNotNull(entry, "entry should not be null");
            Assert.AreEqual(4, entry.Count, "4 lines should be returned");
            Assert.AreEqual(lines[8], entry[0]);
            Assert.AreEqual(lines[9], entry[1]);
            Assert.AreEqual(lines[10], entry[2]);

            entry = documentParser.GetEntryByPosition(lines, 3).ToList();
            Assert.IsNotNull(entry, "entry should not be null");
            Assert.AreEqual(4, entry.Count, "4 lines should be returned");
            Assert.AreEqual(lines[12], entry[0]);
            Assert.AreEqual(lines[13], entry[1]);
            Assert.AreEqual(lines[14], entry[2]);
        }