public void Comma_delimited_data_containing_negative_numbers_throws_an_exception(params int[] numbers)
        {
            var data = string.Join(",", numbers);
            var negatives = numbers.Where(i => i < 0).ToArray();
            var expectedException = new UnparseableDataException(data).ContainsNegatives(negatives);

            var exception = Assert.Throws<UnparseableDataException>(() => new StringCalculator(data).Sum());

            Assert.That(exception, Is.EqualTo(expectedException));
        }
        public void Custom_char_delimited_data_containing_negative_numbers_throws_an_exception(params int[] numbers)
        {
            var data = TestDataBuilder.GetCharDelimitedData('^', numbers);
            var negatives = numbers.Where(i => i < 0).ToArray();
            var expectedException = new UnparseableDataException(data).ContainsNegatives(negatives);

            var exception = Assert.Throws<UnparseableDataException>(() => new StringCalculator(data).Sum());

            Assert.That(exception, Is.EqualTo(expectedException));
        }
Exemplo n.º 3
0
 public void Exception_is_thrown_when_data_is_syntactically_incorrect(string data)
 {
     var expectedException = new UnparseableDataException(data).InvalidSyntax();
     var exception = Assert.Throws<UnparseableDataException>(() => new StringCalculator(data).Sum());
     Assert.That(exception, Is.EqualTo(expectedException));
 }
Exemplo n.º 4
0
 public void Exception_is_thrown_when_an_undefined_custom_delimiter_is_used(string data, string undefinedDelimiter)
 {
     var expectedException = new UnparseableDataException(data).UndefinedDelimiters(undefinedDelimiter);
     var exception = Assert.Throws<UnparseableDataException>(() => new StringCalculator(data).Sum());
     Assert.That(exception, Is.EqualTo(expectedException));
 }