Example #1
0
 public void TestMatchType_WillThrowArgumentException_WhenCalledWithInvalidMatchTypeParameter()
 {
     try
     {
         UserInput userInput = new UserInput(new string[] { POSITIVE_TEST_NEWS_FILE_PATH, "aaa", "Care" });
         Assert.Fail("Expected {0} to be thrown.", typeof(ArgumentException));
     }
     catch (Exception ex)
     {
         Assert.AreEqual(ex.GetType(), typeof(ArgumentException));
     }
 }
Example #2
0
 public void TestFilePath_WillThrowFileNotFoundException_WhenCalledWithNonExistantFilePath()
 {
     try
     {
         UserInput userInput = new UserInput(new string[] { "filethatdoesnotexist.txt", "AND", "Care" });
         Assert.Fail("Expected {0} to be thrown.", typeof(FileNotFoundException));
     }
     catch (Exception ex)
     {
         Assert.AreEqual(typeof(FileNotFoundException), ex.GetType());
     }
 }
Example #3
0
 public void TestFilePath_WillSetFilePathProperty_WhenCalled()
 {
     try
     {
         UserInput userInput = new UserInput(new string[] { POSITIVE_TEST_NEWS_FILE_PATH, "AND", "Care" });
         Assert.AreEqual(POSITIVE_TEST_NEWS_FILE_PATH, userInput.FilePath);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Example #4
0
 public ConsoleContext(ApplicationContext appContext, UserInput userInput = null)
 {
     UserInput  = userInput;
     AppContext = appContext;
 }
Example #5
0
 public void TestSearchTerm_WillSetThreeSearchTerms_WhenCalledWithFiveValidArguments()
 {
     UserInput userInput = new UserInput(new string[] { POSITIVE_TEST_NEWS_FILE_PATH, "and", "Care", "Quality", "Commission" });
     Assert.AreEqual("Care,Quality,Commission", string.Join(",", userInput.Terms));
 }
Example #6
0
 public void TestSearchTerm_WillSetSingleSearchTerm_WhenCalledWithSingleSearchTerm()
 {
     UserInput userInput = new UserInput(new string[] { POSITIVE_TEST_NEWS_FILE_PATH, "and", "Care" });
     Assert.AreEqual("Care", string.Join(",", userInput.Terms));
 }
Example #7
0
 public void TestMatchType_WillSetMatchTypeToOr_WhenCalledWithOrParameter()
 {
     UserInput userInput = new UserInput(new string[] { POSITIVE_TEST_NEWS_FILE_PATH, "or", "Care" });
     Assert.AreEqual(MatchType.Or, userInput.MatchType);
 }
Example #8
0
 public void TestMatchType_WillSetMatchTypeToAnd_WhenCalledWithAndParameterInUppercase()
 {
     UserInput userInput = new UserInput(new string[] { POSITIVE_TEST_NEWS_FILE_PATH, "AND", "Care" });
     Assert.AreEqual(MatchType.And, userInput.MatchType);
 }
Example #9
0
 public void TestSearchTerm_WillTrowArgumentException_WhenCalledWithTwoArguments()
 {
     try
     {
         UserInput userInput = new UserInput(new string[] { POSITIVE_TEST_NEWS_FILE_PATH, "and" });
         Assert.Fail();
     }
     catch (Exception ex)
     {
         Assert.AreEqual(ex.GetType(), typeof(ArgumentException));
     }
 }