public void check_if_action_and_save_in_file_works()
        {
            var given = "1,2,3";
            var ouputThatShouldBeInTheFile = given + " el resultado es: 6";

            controlador.Execute(given, path);


            var linesInTheFile = File.ReadAllLines(path).Last();

            linesInTheFile.Should().Be(ouputThatShouldBeInTheFile);
        }
示例#2
0
        public void write_operation_with_result_in_file()
        {
            var operation = "1,2";

            saveAction.Execute(operation);

            using (StreamReader streamReader = new StreamReader(filePath))
            {
                var lineInFile = streamReader.ReadToEnd().Trim();
                lineInFile.Should().Be(operation + " -> El resultado es 3");
            }
        }
示例#3
0
        public ActionResult <StringCalculatorResult> PostStringCalculatora(StringCalculatorRequest request)
        {
            var saveAction             = new SaveAction(new StringCalculator(), new PersistenceFile(@"..\OperationLog.txt"));
            var stringCalculatorResult = saveAction.Execute(request.Numbers);

            if (stringCalculatorResult == null)
            {
                return(BadRequest(new ErrorMessage()
                {
                    Error = "Negative numbers not allowed"
                }));
            }
            return(stringCalculatorResult);
        }