Ejemplo n.º 1
0
 public void Add_Given2Digits_ShouldReturnTheSum()
 {
     //---------------Set up test pack-------------------
     const string input = "1,2";
     const int expected = 3;
     var calculator = new Calculator();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var result = calculator.Add(input);
     //---------------Test Result -----------------------
     Assert.AreEqual(expected, result);
 }
Ejemplo n.º 2
0
 public void Add_Given1Digit_ShouldReturnIntegerValueOfDigit()
 {
     //---------------Set up test pack-------------------
     const string input = "1";
     const int expected = 1;
     var calculator = new Calculator();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var result = calculator.Add(input);
     //---------------Test Result -----------------------
     Assert.AreEqual(expected, result);
 }
Ejemplo n.º 3
0
 public void Add_GivenNegativeNumber_ShouldThrowException()
 {
     //---------------Set up test pack-------------------
     const string input = "-1,-2,3";
     const string expected = "negatives not allowed: -1-2";
     var calculator = new Calculator();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var exception = Assert.Throws<Exception>(() => calculator.Add(input));
     //---------------Test Result -----------------------
     Assert.AreEqual(expected, exception.Message);
 }
Ejemplo n.º 4
0
 public void Add_GivenDigitsGreaterthan1000_ShouldIgnoreTheDigit()
 {
     //---------------Set up test pack-------------------
     const string input = "3,1003";
     const int expected = 3;
     var calculator = new Calculator();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var result = calculator.Add(input);
     //---------------Test Result -----------------------
     Assert.AreEqual(expected, result);
 }
Ejemplo n.º 5
0
 public void Add_Given3DigitsWithCustomDelimiter_ShouldReturnTheSum()
 {
     //---------------Set up test pack-------------------
     const string input = "//;\n1;2;3";
     const int expected = 6;
     var calculator = new Calculator();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var result = calculator.Add(input);
     //---------------Test Result -----------------------
     Assert.AreEqual(expected, result);
 }