public void TestConstructorWithValidFile() { InputFile file = InputFile.GetInputFile(TestFileNameContents.Example2FileName); //If no exception is thrown, this test passes Assert.IsTrue(true); }
public void TestGetWordAtIndexWithValidIndex() { int testIndex = 3; InputFile file = InputFile.GetInputFile(TestFileNameContents.Example2FileName); Assert.AreEqual("plan", file.GetWordAtIndex(testIndex)); }
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]); }
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]); }
public void TestConstructorWithInvalidFile() { try { InputFile file = InputFile.GetInputFile(TestFileNameContents.MissingFileName); } catch (FileNotFoundException e) { Assert.AreEqual(ErrorMessageConstants.InvalidFileArgumentErrorMessage, e.Message); } }
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); } }
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); } }
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); } }
public void TestGetWordCountWithEmptyFile() { InputFile file = InputFile.GetInputFile(TestFileNameContents.EmptyFileName); Assert.AreEqual(0, file.GetWordCount()); }
public void TestGetWordCount() { InputFile file = InputFile.GetInputFile(TestFileNameContents.Example2FileName); Assert.AreEqual(21, file.GetWordCount()); }