public void Add_Given_StringOfSingleNumber_ShouldReturnItself() { //---------------Set up test pack------------------- const string input = "1"; const int expected = 1; var calculate = new Calculate(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = calculate.Add(input); //---------------Test Result ----------------------- Assert.AreEqual(expected, result); }
public void Add_Given_CustomDelimiter_ShouldReturnSum() { //---------------Set up test pack------------------- const string input = "//;\n1;2,3"; const int expected = 6; var calculate = new Calculate(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = calculate.Add(input); //---------------Test Result ----------------------- Assert.AreEqual(expected, result); }
public void Add_Given_EmptyString_ShouldReturn0() { //---------------Set up test pack------------------- const string input = ""; const int expected = 0; var calculate = new Calculate(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = calculate.Add(input); //---------------Test Result ----------------------- Assert.AreEqual(expected, result); }
public void Add_Given_NumbersGreaterThanOneThousand_ShouldReturnSum() { //---------------Set up test pack------------------- const string input = "2000,3"; const int expected = 3; var calculate = new Calculate(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = calculate.Add(input); //---------------Test Result ----------------------- Assert.AreEqual(expected, result); }
public void Add_Given_NegativeNumbers_ShouldThrow() { //---------------Set up test pack------------------- const string input = "//;\n1;2,-3"; const string expected = "Negative Numbers Not Allowed"; var calculate = new Calculate(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = Assert.Throws<Exception>(() => calculate.Add(input)); //---------------Test Result ----------------------- Assert.AreEqual(expected, result.Message); }