Пример #1
0
        public void whenNegativeNumbersAreUsedThenRuntimeExceptionIsThrown()
        {
            TestDelegate code = () => StringCalculator7.Add("3,-6,15,-18,46,33");

            Assert.Throws(Is.TypeOf <ArgumentException>().And.Message.EqualTo("Negatives not allowed: -6,-18"), code);
        }
Пример #2
0
 public void when2NumbersAreUsedThenNoExceptionIsThrown()
 {
     Assert.DoesNotThrow(() => StringCalculator7.Add("1,2"));
 }
Пример #3
0
 public void whenNewLineIsUsedBetweenNumbersThenReturnValuesAreTheirSums()
 {
     Assert.AreEqual(3 + 6 + 15, StringCalculator7.Add("3,6\n15"));
 }
Пример #4
0
 public void whenDelimeterIsSpecifiedThenItIsUsedToSeparateNumbers()
 {
     Assert.AreEqual(3 + 6 + 15, StringCalculator7.Add("//;\n3;6;15"));
 }
Пример #5
0
 public void whenAnyNumberOfNumbersIsUsedThenReturnValueAreTheirSums()
 {
     Assert.AreEqual(3 + 6 + 15 + 18 + 46 + 33, StringCalculator7.Add("3,6,15,18,46,33"));
 }
Пример #6
0
 public void whenTwoNumbresAreUsedThenReturnValueIsTheirSum()
 {
     Assert.AreEqual(3 + 6, StringCalculator7.Add("3,6"));
 }
Пример #7
0
 public void whenOneIsUsedThenReturnValueIsThatSameNumber()
 {
     Assert.AreEqual(3, StringCalculator7.Add("3"));
 }
Пример #8
0
 public void whenEmptyStringIsUsedThenReturnValueIs0()
 {
     Assert.AreEqual(0, StringCalculator7.Add(""));
 }
Пример #9
0
 public void whenNonNumberIsUsedThenExceptionIsThrown()
 {
     Assert.Throws(typeof(FormatException), () => StringCalculator7.Add("1,x"));
 }