Exemple #1
0
        public void ShouldAcceptStringWithNumberAndComma_AndReturn_Sum(string s, int ris)
        {
            var test = StringCalculator.Add(s);

            Assert.That(test, Is.EqualTo(ris));
        }
Exemple #2
0
        public void ShouldAcceptStringWithMoreNumbersAndCustomizedSeparatorsAnd_AndReturn_Sum(string s, int ris)
        {
            var test = StringCalculator.Add(s);

            Assert.That(test, Is.EqualTo(ris));
        }
Exemple #3
0
 public void MultipleDelimitors()
 {
     Assert.AreEqual(34, StringCalculator.Calculate("//[,][$][@]\n10,9$8@7"));
 }
        public void Should_return_sum_of_several_numbers_in_input_string()
        {
            var actual = StringCalculator.Add("1,2,3");

            Check.That(actual).IsEqualTo(6);
        }
Exemple #5
0
 public void NewLineDelimitor()
 {
     Assert.AreEqual(9, StringCalculator.Calculate("5 \n 4"));
 }
Exemple #6
0
 public void NegativeInNumbersToAdd()
 {
     StringCalculator.Calculate("-2,-3");
 }
 public void Should_allow_custom_delimiter_greater_than_one_character()
 {
     Check.That(StringCalculator.Add("//[***]\n1***2***3")).IsEqualTo(6);
 }
Exemple #8
0
 public void BlankString()
 {
     Assert.AreEqual(0, StringCalculator.Calculate(""));
 }
 public void Should_specify_negative_numbers_in_error_message()
 {
     Check.ThatCode(() => StringCalculator.Add("-1,-2")).Throws <Exception>().WithMessage("negatives not allowed: -1,-2");
 }
 public void Should_ignore_number_when_it_is_bigger_than_1000()
 {
     Check.That(StringCalculator.Add("1001, 2")).IsEqualTo(2);
 }
 public void Should_raise_an_exception_when_number_is_negative()
 {
     Check.ThatCode(() => StringCalculator.Add("-1")).Throws <Exception>().WithMessage("negatives not allowed: -1");
 }
        public void Should_accept_custom_delimiter()
        {
            var actual = StringCalculator.Add("//;\n1;2");

            Check.That(actual).IsEqualTo(3);
        }
        public void Should_return_sum_when_the_delimiter_is_new_line()
        {
            var actual = StringCalculator.Add("1\n2,3");

            Check.That(actual).IsEqualTo(6);
        }
Exemple #14
0
 public void TwoNumberString()
 {
     Assert.AreEqual(7, StringCalculator.Calculate("3 , 4"));
 }
 public void Should_allow_multiple_custom_delimiters_greater_than_one_character()
 {
     Check.That(StringCalculator.Add("//[*][%]\n1*2%3")).IsEqualTo(6);
 }
Exemple #16
0
 public void TwoNumberString2()
 {
     Assert.AreEqual(9, StringCalculator.Calculate("5 , 4"));
 }
        public void Should_return_zero_when_the_string_number_is_empty()
        {
            int actual = StringCalculator.Add(string.Empty);

            Check.That(actual).IsZero();
        }
Exemple #18
0
 public void OneNumberString()
 {
     Assert.AreEqual(5, StringCalculator.Calculate("5"));
 }
Exemple #19
0
        public void ShouldAcceptString_AndReturn_int(string s)
        {
            var test = StringCalculator.Add(s);

            Assert.That(test is int);
        }
Exemple #20
0
 public void CustomDelimitor()
 {
     Assert.AreEqual(10, StringCalculator.Calculate("//JimIsAwesome\n5JimIsAwesome5"));
 }
Exemple #21
0
        public void ShouldAcceptEmptyString_AndReturn_0(string s)
        {
            var test = StringCalculator.Add(s);

            Assert.That(test, Is.EqualTo(0));
        }
Exemple #22
0
 public void IgnoreOverOneThousand()
 {
     Assert.AreEqual(5, StringCalculator.Calculate("//JimIsAwesome\n5JimIsAwesome1001"));
 }
Exemple #23
0
        public void ShouldAcceptStringWithNumber_AndReturn_Number(string n)
        {
            var test = StringCalculator.Add(n);

            Assert.That(test, Is.EqualTo(Int32.Parse(n)));
        }
 public void SetUp()
 {
     _stringCalculator = new StringCalculator();
 }
        public void Should_return_plain_number_when_only_one_number_in_string(string numbers, int expected)
        {
            var actual = StringCalculator.Add(numbers);

            Check.That(actual).IsEqualTo(expected);
        }