Example #1
0
 public void DelimetersCanBeOfAnylength()
 {
     Assert.Equal(6, StringCalculator.Add("//[***]\n1***2***3"));
     Assert.Equal(6, StringCalculator.Add("//[delimeter]\n1delimeter2delimeter3"));
 }
Example #2
0
 public void HandlesMultipleDelimeters()
 {
     Assert.Equal(6, StringCalculator.Add("//[-][%]\n1-2%3"));
     Assert.Equal(6, StringCalculator.Add("//[delim][*&^]\n1delim2*&^3"));
 }
Example #3
0
 public void EmptyStringReturnsZero()
 {
     Assert.Equal(0, StringCalculator.Add(""));
 }
Example #4
0
 public void NumbersBiggerThan1000AreIgnored()
 {
     Assert.Equal(0, StringCalculator.Add("1000"));
     Assert.Equal(5, StringCalculator.Add("1000,3,2"));
     Assert.Equal(1, StringCalculator.Add(@"//~\1000~1"));
 }
Example #5
0
 public void NegativeNumbersInInputThrowsException()
 {
     Assert.Throws <Exception>(() => StringCalculator.Add("-1"));
     Assert.Throws <Exception>(() => StringCalculator.Add("-1,4"));
 }
Example #6
0
 public void WorksWithCommaAndLineBreakDelimeterMixture()
 {
     Assert.Equal(6, StringCalculator.Add("1\n2,3"));
 }
Example #7
0
 public void WorksWithLineBreakDelimeter()
 {
     Assert.Equal(0, StringCalculator.Add("0\n0"));
     Assert.Equal(6, StringCalculator.Add("4\n2"));
     Assert.Equal(10, StringCalculator.Add("2\n1\n7"));
 }
Example #8
0
 public void ManyNumbersSumCorrectly()
 {
     Assert.Equal(0, StringCalculator.Add("0,0,0,0,0"));
     Assert.Equal(10, StringCalculator.Add("1,2,3,4"));
     Assert.Equal(233, StringCalculator.Add("104,51,78"));
 }
Example #9
0
 public void SingleNumbersSumsCorrectly()
 {
     Assert.Equal(1, StringCalculator.Add("1"));
     Assert.Equal(2, StringCalculator.Add("2"));
     Assert.Equal(56, StringCalculator.Add("56"));
 }