Beispiel #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));
     }
 }
Beispiel #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());
     }
 }
Beispiel #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);
     }
 }
 public ConsoleContext(ApplicationContext appContext, UserInput userInput = null)
 {
     UserInput  = userInput;
     AppContext = appContext;
 }
Beispiel #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));
 }
Beispiel #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));
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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));
     }
 }