Ejemplo n.º 1
0
        public void TestGetWordsInRangeWithValidRange()
        {
            int       testRange      = 2;
            int       testStartIndex = 0;
            InputFile file           = InputFile.GetInputFile(TestFileNameContents.Example2FileName);

            string[] words = file.GetWordsInRange(testStartIndex, testRange);
            Assert.AreEqual(testRange, words.Length);
            Assert.AreEqual("the", words[0]);
            Assert.AreEqual("man", words[1]);
        }
Ejemplo n.º 2
0
        public void TestGetWordsInRangeWithValidRangeThatExtendsPastEndOfTestFile()
        {
            int       testRange      = 6;
            int       testStartIndex = 19;
            InputFile file           = InputFile.GetInputFile(TestFileNameContents.Example2FileName);

            string[] words = file.GetWordsInRange(testStartIndex, testRange);
            Assert.AreEqual(2, words.Length);
            Assert.AreEqual("canal", words[0]);
            Assert.AreEqual("panama", words[1]);
        }
Ejemplo n.º 3
0
        public void TestGetWordsInRangeWithZeroRange()
        {
            int       testRange      = 0;
            int       testStartIndex = 0;
            InputFile file           = InputFile.GetInputFile(TestFileNameContents.Example2FileName);

            try
            {
                file.GetWordsInRange(testStartIndex, testRange);
            }
            catch (ArgumentException e)
            {
                Assert.AreEqual(ErrorMessageConstants.InvalidInputFileIndexErrorMessage, e.Message);
            }
        }
Ejemplo n.º 4
0
        public void TestGetWordsInRangeWithStartIndexGreaterThanNumberOfWordsInInputFile()
        {
            int       testRange             = 2;
            int       testStartIndexInvalid = 5000;
            InputFile file = InputFile.GetInputFile(TestFileNameContents.Example2FileName);

            try
            {
                file.GetWordsInRange(testStartIndexInvalid, testRange);
            }
            catch (ArgumentException e)
            {
                Assert.AreEqual(ErrorMessageConstants.InvalidInputFileIndexErrorMessage, e.Message);
            }
        }