public void GenerateProblemsWithOptionalParameters()
        {
            var service = new MathService();

            var expectedProblems = 4;
            var minOperations    = 2;
            var maxOperations    = 3;

            var expressions = service.Generate(expectedProblems, minOperations, maxOperations);

            var problems = expressions.Split('\n');

            problems = problems.Take(problems.Length - 1).ToArray();

            foreach (var problem in problems)
            {
                var count1 = problem.Distinct().Count(x => x == '+');
                var count2 = problem.Distinct().Count(x => x == '-');
                var count3 = problem.Distinct().Count(x => x == '*');
                var count4 = problem.Distinct().Count(x => x == '/');
                var count  = count1 + count2 + count3 + count4;

                Assert.IsTrue(minOperations <= count && maxOperations >= count);
            }
        }
        public void GenerateZeroProblems()
        {
            var service = new MathService();

            var expressions = service.Generate(0, null, null);

            Assert.AreEqual("No problems to generate", expressions);
        }
        public void GenerateNegativeProblems()
        {
            var service = new MathService();

            var expectedProblems = -4;

            var expressions = service.Generate(expectedProblems, null, null);
        }
        public void OutOfRangeMinOperations()
        {
            var service = new MathService();

            var expectedProblems = 4;
            var minOperations    = -2;

            var expressions = service.Generate(expectedProblems, minOperations, null);
        }
        public void MinOperationsGreaterThanMaxOperations()
        {
            var service = new MathService();

            var expectedProblems = 4;
            var minOperations    = 3;
            var maxOperations    = 1;

            var expressions = service.Generate(expectedProblems, minOperations, maxOperations);
        }
        public void GenerateDivideByZeroProblem()
        {
            var service = new MathService();

            var expectedProblems = 20;

            var expressions = service.Generate(expectedProblems, null, null);

            var indexOfZero = expressions.IndexOf("/ 0", StringComparison.Ordinal);

            Assert.AreEqual(-1, indexOfZero);
        }
        public void GenerateProblems()
        {
            var service = new MathService();

            var expectedProblems = 4;

            var expressions = service.Generate(expectedProblems, null, null);

            var numProblems = expressions.Split('\n').Length - 1;

            Assert.AreEqual(expectedProblems, numProblems);
        }