public IActionResult GetLinearSimultaneousEquations()
 {
     return(ControllerTryCatchBlocks.LoggingAllExceptions(logger, () =>
     {
         var equationGenerator = new LinearSimultaneousEquationsGenerator(randomIntegerGenerator);
         return Ok(equationGenerator.GenerateQuestionAndAnswer());
     }));
 }
示例#2
0
        public void TestLotsOfSimultaneousEquations()
        {
            var integerGenerator  = new FixedRandomIntegerGenerator(346);
            var equationGenerator = new LinearSimultaneousEquationsGenerator(integerGenerator);

            for (int i = 0; i < 1000000; i++)
            {
                var equation  = equationGenerator.GenerateQuestionAndAnswer();
                var isCorrect = VerifySolutionIfSolutionExists(equation.Coefficients, equation.Solution);
                Assert.IsTrue(isCorrect, $"{i}");
            }
        }
        public IActionResult GetLinearSimultaneousEquations([FromBody] LinearSimultaneousEquationsGeneratorParameters parameters)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(ControllerTryCatchBlocks.ReturnBadRequestOnFailedToGenerateExceptionLoggingAllOthers(logger, () =>
            {
                var equationGenerator = new LinearSimultaneousEquationsGenerator(randomIntegerGenerator, parameters);
                return Ok(equationGenerator.GenerateQuestionAndAnswer());
            },
                                                                                                        BadRequest, parameters));
        }