public void DelimetersCanBeOfAnylength() { Assert.Equal(6, StringCalculator.Add("//[***]\n1***2***3")); Assert.Equal(6, StringCalculator.Add("//[delimeter]\n1delimeter2delimeter3")); }
public void HandlesMultipleDelimeters() { Assert.Equal(6, StringCalculator.Add("//[-][%]\n1-2%3")); Assert.Equal(6, StringCalculator.Add("//[delim][*&^]\n1delim2*&^3")); }
public void EmptyStringReturnsZero() { Assert.Equal(0, StringCalculator.Add("")); }
public void NumbersBiggerThan1000AreIgnored() { Assert.Equal(0, StringCalculator.Add("1000")); Assert.Equal(5, StringCalculator.Add("1000,3,2")); Assert.Equal(1, StringCalculator.Add(@"//~\1000~1")); }
public void NegativeNumbersInInputThrowsException() { Assert.Throws <Exception>(() => StringCalculator.Add("-1")); Assert.Throws <Exception>(() => StringCalculator.Add("-1,4")); }
public void WorksWithCommaAndLineBreakDelimeterMixture() { Assert.Equal(6, StringCalculator.Add("1\n2,3")); }
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")); }
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")); }
public void SingleNumbersSumsCorrectly() { Assert.Equal(1, StringCalculator.Add("1")); Assert.Equal(2, StringCalculator.Add("2")); Assert.Equal(56, StringCalculator.Add("56")); }