コード例 #1
0
 public void Add_Handles_Multiple_Single_Character_Delimiters()
 {
     string calcProgram = "//[*][%]\n1*2%3";
     StringCalculator calc = new StringCalculator();
     int result = calc.Add(calcProgram);
     Assert.AreEqual(6, result);
 }
コード例 #2
0
 public void Add_Handles_Multi_Character_Delimiter()
 {
     string calcProgram = "//[***]\n1***2***3";
     StringCalculator calc = new StringCalculator();
     int result = calc.Add(calcProgram);
     Assert.AreEqual(6, result);
 }
コード例 #3
0
 public void Add_SumsTwoNumbers_SeparatedByComma()
 {
     StringCalculator calc = new StringCalculator();
     int result = calc.Add("1,2");
     Assert.AreEqual(3, result);
 }
コード例 #4
0
 public void Add_SumsSingleNumber()
 {
     StringCalculator calc = new StringCalculator();
     int result = calc.Add("1");
     Assert.AreEqual(1, result);
 }
コード例 #5
0
 public void Add_SumsMultipleNumbers_SeparatedByComma()
 {
     StringCalculator calc = new StringCalculator();
     int result = calc.Add("1,2,3,4");
     Assert.AreEqual(10, result);
 }
コード例 #6
0
 public void Add_SumsEmptyString()
 {
     StringCalculator calc = new StringCalculator();
     int result = calc.Add("");
     Assert.AreEqual(0, result);
 }
コード例 #7
0
 public void Add_Ingores_Numbers_Larger_Than_1000()
 {
     StringCalculator calc = new StringCalculator();
     int result = calc.Add("2,1001");
     Assert.AreEqual(2, result);
 }
コード例 #8
0
 public void Add_DefaultDelimiterSpecifiedFirstLine()
 {
     StringCalculator calc = new StringCalculator();
     int result = calc.Add("//;\n1;2");
     Assert.AreEqual(3, result);
 }
コード例 #9
0
 public void Add_Allows_Comma_Or_Newline_Delimiters()
 {
     StringCalculator calc = new StringCalculator();
     int result = calc.Add("1\n2,3");
     Assert.AreEqual(6, result);
 }
コード例 #10
0
 public void Add_With_Negative_Number_Throws_Exception()
 {
     StringCalculator calc = new StringCalculator();
     int result = calc.Add("-1");
 }
コード例 #11
0
 public void Add_With_Negative_Number_Includes_Number_In_Exception_Message()
 {
     StringCalculator calc = new StringCalculator();
     try
     {
         int result = calc.Add("-1");
     }
     catch (Exception exception)
     {
         Assert.IsTrue(exception.Message.Contains("-1"));
     }
 }
コード例 #12
0
 public StringCalculatorFacts()
 {
     stringCalculator = new StringCalculator();
 }