Ejemplo n.º 1
0
        public async Task ProcessStringToSentencesToXMLFormat()
        {
            string input = "Mary had a little lamb. Peter called for the wolf, and Aesop came. Cinderella likes shoes.";

            var result = await _sut.ProcessSentenceAsync(input);

            var formattedResult = await _sut.ConvertSentencesAsync(result, WordConvertingMethod.XML);

            Assert.NotEmpty(formattedResult);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PostConvert([FromBody] WordProcessingRequest request)
        {
            var processResult = await _wordProcessingService.ProcessSentenceAsync(request.SentenceStrings);

            if (processResult != null)
            {
                WordConvertingMethod method = ParseStringToEnum(request.ConvertMethod);
                string convertResult        = await _wordProcessingService.ConvertSentencesAsync(processResult, method);

                if (!string.IsNullOrEmpty(convertResult))
                {
                    return(Ok(convertResult));
                }
            }
            return(BadRequest());
        }
Ejemplo n.º 3
0
        public async Task WordProcrssingControllerBasicTest_Success(string convertMethodString, string stringToConvert)
        {
            _wordProcessingService.ProcessSentenceAsync(Arg.Any <string>()).Returns(_sentenceParseResult);
            _wordProcessingService.ConvertSentencesAsync(Arg.Any <SentenceProcessResult>(), Arg.Any <WordConvertingMethod>()).Returns("<xml>result</xml>");
            WordProcessingController _sut = new WordProcessingController(_wordProcessingService);

            var response = await _sut.PostConvert(new Models.Requests.WordProcessingRequest()
            {
                ConvertMethod = convertMethodString, SentenceStrings = stringToConvert
            });

            var okResult = response as OkObjectResult;

            // assert
            Assert.NotNull(okResult);
            Assert.Equal(200, okResult.StatusCode);
        }