Ejemplo n.º 1
0
        public void TestConstructorWithValidFile()
        {
            InputFile file = InputFile.GetInputFile(TestFileNameContents.Example2FileName);

            //If no exception is thrown, this test passes
            Assert.IsTrue(true);
        }
Ejemplo n.º 2
0
        public void TestGetWordAtIndexWithValidIndex()
        {
            int       testIndex = 3;
            InputFile file      = InputFile.GetInputFile(TestFileNameContents.Example2FileName);

            Assert.AreEqual("plan", file.GetWordAtIndex(testIndex));
        }
Ejemplo n.º 3
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.º 4
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.º 5
0
 public void TestConstructorWithInvalidFile()
 {
     try
     {
         InputFile file = InputFile.GetInputFile(TestFileNameContents.MissingFileName);
     }
     catch (FileNotFoundException e)
     {
         Assert.AreEqual(ErrorMessageConstants.InvalidFileArgumentErrorMessage, e.Message);
     }
 }
Ejemplo n.º 6
0
        public void TestGetWordAtIndexWithInvalidIndex()
        {
            int       testIndex = 3;
            InputFile file      = InputFile.GetInputFile(TestFileNameContents.Example2FileName);

            try
            {
                file.GetWordAtIndex(testIndex);
            }
            catch (ArgumentException e)
            {
                Assert.AreEqual(ErrorMessageConstants.InvalidInputFileIndexErrorMessage, e.Message);
            }
        }
Ejemplo n.º 7
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.º 8
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);
            }
        }
Ejemplo n.º 9
0
        public void TestGetWordCountWithEmptyFile()
        {
            InputFile file = InputFile.GetInputFile(TestFileNameContents.EmptyFileName);

            Assert.AreEqual(0, file.GetWordCount());
        }
Ejemplo n.º 10
0
        public void TestGetWordCount()
        {
            InputFile file = InputFile.GetInputFile(TestFileNameContents.Example2FileName);

            Assert.AreEqual(21, file.GetWordCount());
        }