Пример #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"));
 }