public void throwsExceptionGivenNegs() { // Arrange String input = "-4,3,-2"; var s = new StringCalc(); // Act var result = Assert.Throws <Exception>(() => s.Add(input)); // Assert Assert.Equal("Negatives not allowed: -4,-2", result.Message); }
public void returnsSumGivenUserInputDelimiter() { // Arrange String input = "//;\n5,1\n6;3"; var s = new StringCalc(); // Act int output = s.Add(input); // Assert Assert.Equal(15, output); }
public void returns0GivenEmpty() { // Arrange String input = ""; var s = new StringCalc(); // Act int output = s.Add(input); // Assert Assert.Equal(0, output); }
public void returnsSumGivenManyNum() { // Arrange String input = "5,21,7,13"; var s = new StringCalc(); // Act int output = s.Add(input); // Assert Assert.Equal(46, output); }
public void returnsSumGivenNewLineDelimiter() { // Arrange String input = "5,1\n6"; var s = new StringCalc(); // Act int output = s.Add(input); // Assert Assert.Equal(12, output); }
public void returnsNumGivenOneNum() { // Arrange String input = "5"; var s = new StringCalc(); // Act int output = s.Add(input); // Assert Assert.Equal(5, output); }
public void returnsSumGivenTwoNum() { // Arrange String input = "5,2"; var s = new StringCalc(); // Act int output = s.Add(input); // Assert Assert.Equal(7, output); }
public void IgnoresNumsOver1000() { // Arrange String input = "1000,2"; var s = new StringCalc(); // Act int output = s.Add(input); // Assert Assert.Equal(2, output); }
public void returnsSumGivenDefinedDelimiter() { // Arrange String input = "//&\n0&7&5"; var s = new StringCalc(); // Act int output = s.Add(input); // Assert Assert.Equal(12, output); }
public void returnsSumGivenNewLineSeparator() { // Arrange String input = "1\n4,7"; var s = new StringCalc(); // Act int output = s.Add(input); // Assert Assert.Equal(12, output); }
public void returnsSumGivenFiveNum() { // Arrange String input = "11,5,7,3,1"; var s = new StringCalc(); // Act int output = s.Add(input); // Assert Assert.Equal(27, output); }
public void returnsNegsException() { // Arrange String input = "-1,0,-5"; var s = new StringCalc(); // Act //int output = s.Add(input); var result = Assert.Throws <Exception>(() => s.Add(input)); // Assert Assert.Equal("Negatives not allowed: -1,-5", result.Message); }