コード例 #1
0
 public void when2NumbersAreUsedThenNoExceptionIsThrown()
 {
     Assert.DoesNotThrow(() => StringCalculator8.Add("1,2"));
 }
コード例 #2
0
        public void whenNegativeNumbersAreUsedThenRuntimeExceptionIsThrown()
        {
            TestDelegate code = () => StringCalculator8.Add("3,-6,15,-18,46,33");

            Assert.Throws(Is.TypeOf <ArgumentException>().And.Message.EqualTo("Negatives not allowed: -6,-18"), code);
        }
コード例 #3
0
 public void whenOneOrMoreNumbersAreGreaterThan1000IsUsedThenItIsNotIncludedInSum()
 {
     Assert.AreEqual(3 + 1000 + 6, StringCalculator8.Add("3,1000,1001,6,1234"));
 }
コード例 #4
0
 public void whenNewLineIsUsedBetweenNumbersThenReturnValuesAreTheirSums()
 {
     Assert.AreEqual(3 + 6 + 15, StringCalculator8.Add("3,6\n15"));
 }
コード例 #5
0
 public void whenDelimeterIsSpecifiedThenItIsUsedToSeparateNumbers()
 {
     Assert.AreEqual(3 + 6 + 15, StringCalculator8.Add("//;\n3;6;15"));
 }
コード例 #6
0
 public void whenAnyNumberOfNumbersIsUsedThenReturnValueAreTheirSums()
 {
     Assert.AreEqual(3 + 6 + 15 + 18 + 46 + 33, StringCalculator8.Add("3,6,15,18,46,33"));
 }
コード例 #7
0
 public void whenTwoNumbresAreUsedThenReturnValueIsTheirSum()
 {
     Assert.AreEqual(3 + 6, StringCalculator8.Add("3,6"));
 }
コード例 #8
0
 public void whenOneIsUsedThenReturnValueIsThatSameNumber()
 {
     Assert.AreEqual(3, StringCalculator8.Add("3"));
 }
コード例 #9
0
 public void whenEmptyStringIsUsedThenReturnValueIs0()
 {
     Assert.AreEqual(0, StringCalculator8.Add(""));
 }
コード例 #10
0
 public void whenNonNumberIsUsedThenExceptionIsThrown()
 {
     Assert.Throws(typeof(FormatException), () => StringCalculator8.Add("1,x"));
 }