<commit_before>using System;
using System.Globalization;
using System.Linq;
using Ploeh.AutoFixture;
using TestStack.BDDfy;
using TestStack.BDDfy.Scanners.StepScanners.Fluent;

namespace StringCalculator.BDDfy.Fixie.UnitTests
{
    public class CalculatorTests : CalculatorOrchestration
    {
        [CalculatorTestConventions]
        public void AddEmptyReturnsCorrectResult(Calculator sut)
        {
            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(""))
                .Then(t => t.ThenTheExpectedResultShouldBe(0))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddSingleNumberReturnsCorrectResult(
            Calculator sut,
            int expected)
        {
            var numbers = expected.ToString(CultureInfo.InvariantCulture);

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddTwoNumbersReturnsCorrectResult(
            Calculator sut,
            int x,
            int y)
        {
            var numbers = string.Join(",", x, y).ToString(CultureInfo.InvariantCulture);
            var expected = x + y;

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddAnyAmountOfNumbersReturnsCorrectResult(
            Calculator sut,
            int count,
            Generator<int> generator)
        {
            var intergers = Enumerable.Take<int>(generator, count + 2).ToArray();
            var numbers = string.Join(",", intergers);
            var expected = intergers.Sum();

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddWithLineBreakAndCommaAsDelimiterRetunrsCorrectResult(
            Calculator sut,
            int x,
            int y,
            int z)
        {
            var numbers = string.Format("{0}\n{1},{2}", x, y, z);
            var expected = x + y + z;

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddLineWithCustomDelimiterReturnsCorrectResult(
            Calculator sut,
            Generator<char> charGenerator,
            int count,
            Generator<int> intGenerator)
        {
            int dummy;
            var delimiter = Enumerable.Where<char>(charGenerator, c => int.TryParse(c.ToString(), out dummy) == false)
                .Where(c => c != '-')
                .First();

            var integers = Enumerable.Take<int>(intGenerator, count).ToArray();
            var numbers = string.Format(
                "//{0}\n{1}",
                delimiter,
                string.Join(delimiter.ToString(), integers));

            var expected = integers.Sum();

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddLineWithNegativeNumberThrowsCorrectException(
            Calculator sut,
            int x,
            int y,
            int z)
        {
            var numbers = string.Join(",", -x, y, -z);
            var negativeX = (-x).ToString();
            var negativeZ = (-z).ToString();

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculatedThrowsArgumentOutOfRangeException(numbers))
                .Then(t => t.ThenExceptionMessageStartsWith("Negatives not allowed."))
                .And(t => t.AndExceptionMessageContains(negativeX))
                .And(t => t.AndExceptionMessageContains(negativeZ))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddIgnoresBigNumbers(
            Calculator sut,
            int smallSeed,
            int bigSeed)
        {
            var x = Math.Min(smallSeed, 1000);
            var y = bigSeed + 1000;
            var numbers = string.Join(",", x, y);
            var expected = x;

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddLineWithCustomDelimiterStringReturnsCorrectResult(
            Calculator sut,
            string delimiter,
            int count,
            Generator<int> intGenerator)
        {
            var integers = Enumerable.Take<int>(intGenerator, count).ToArray();
            var numbers = string.Format(
                "//[{0}]\n{1}",
                delimiter,
                string.Join(delimiter, integers));

            var expected = integers.Sum();

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddLineWithMultipleCustomDelimiterStringsReturnsCorrectResult(
            Calculator sut,
            string delimiter1,
            string delimiter2,
            int x,
            int y,
            int z)
        {
            var numbers = string.Format(
                "//[{0}][{1}]\n{2}{0}{3}{1}{4}",
                delimiter1,
                delimiter2,
                x,
                y,
                z);

            var expected = x + y + z;

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }
    }
}<commit_msg>Renamed tests to match fixie tests convention<commit_after>using System;
using System.Globalization;
using System.Linq;
using Ploeh.AutoFixture;
using TestStack.BDDfy;
using TestStack.BDDfy.Scanners.StepScanners.Fluent;

namespace StringCalculator.BDDfy.Fixie.UnitTests
{
    public class CalculatorTests : CalculatorOrchestration
    {
        [CalculatorTestConventions]
        public void AddEmptyReturnsCorrectResult(Calculator sut)
        {
            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(""))
                .Then(t => t.ThenTheExpectedResultShouldBe(0))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddSingleNumberReturnsCorrectResult(
            Calculator sut,
            int expected)
        {
            var numbers = expected.ToString(CultureInfo.InvariantCulture);

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddTwoNumbersReturnsCorrectResult(
            Calculator sut,
            int x,
            int y)
        {
            var numbers = string.Join(",", x, y).ToString(CultureInfo.InvariantCulture);
            var expected = x + y;

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddAnyAmountOfNumbersReturnsCorrectResult(
            Calculator sut,
            int count,
            Generator<int> generator)
        {
            var intergers = Enumerable.Take<int>(generator, count + 2).ToArray();
            var numbers = string.Join(",", intergers);
            var expected = intergers.Sum();

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddWithLineBreakAndCommaAsDelimiterReturnsCorrectResult(
            Calculator sut,
            int x,
            int y,
            int z)
        {
            var numbers = string.Format("{0}\n{1},{2}", x, y, z);
            var expected = x + y + z;

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddLineWithCustomDelimiterReturnsCorrectResult(
            Calculator sut,
            Generator<char> charGenerator,
            int count,
            Generator<int> intGenerator)
        {
            int dummy;
            var delimiter = Enumerable.Where<char>(charGenerator, c => int.TryParse(c.ToString(), out dummy) == false)
                .Where(c => c != '-')
                .First();

            var integers = Enumerable.Take<int>(intGenerator, count).ToArray();
            var numbers = string.Format(
                "//{0}\n{1}",
                delimiter,
                string.Join(delimiter.ToString(), integers));

            var expected = integers.Sum();

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddLineWithNegativeNumberThrowsCorrectException(
            Calculator sut,
            int x,
            int y,
            int z)
        {
            var numbers = string.Join(",", -x, y, -z);
            var negativeX = (-x).ToString();
            var negativeZ = (-z).ToString();

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculatedThrowsArgumentOutOfRangeException(numbers))
                .Then(t => t.ThenExceptionMessageStartsWith("Negatives not allowed."))
                .And(t => t.AndExceptionMessageContains(negativeX))
                .And(t => t.AndExceptionMessageContains(negativeZ))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddIgnoresBigNumbersReturnsCorrectResult(
            Calculator sut,
            int smallSeed,
            int bigSeed)
        {
            var x = Math.Min(smallSeed, 1000);
            var y = bigSeed + 1000;
            var numbers = string.Join(",", x, y);
            var expected = x;

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddLineWithCustomDelimiterStringReturnsCorrectResult(
            Calculator sut,
            string delimiter,
            int count,
            Generator<int> intGenerator)
        {
            var integers = Enumerable.Take<int>(intGenerator, count).ToArray();
            var numbers = string.Format(
                "//[{0}]\n{1}",
                delimiter,
                string.Join(delimiter, integers));

            var expected = integers.Sum();

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }

        [CalculatorTestConventions]
        public void AddLineWithMultipleCustomDelimiterStringsReturnsCorrectResult(
            Calculator sut,
            string delimiter1,
            string delimiter2,
            int x,
            int y,
            int z)
        {
            var numbers = string.Format(
                "//[{0}][{1}]\n{2}{0}{3}{1}{4}",
                delimiter1,
                delimiter2,
                x,
                y,
                z);

            var expected = x + y + z;

            this.Given(t => t.GivenACalculator(sut))
                .When(t => t.WhenTheResultIsCalculated(numbers))
                .Then(t => t.ThenTheExpectedResultShouldBe(expected))
                .BDDfy();
        }
    }
}
{'fraction_non_alphanumeric': 0.10187110187110188, 'fraction_numerical': 0.004158004158004158, 'mean_word_length': 1.5485335856196782, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5042915', 'n_tokens_mistral': 3870, 'n_tokens_neox': 3464, 'n_words': 644}