public async Task <ActionResult <TextFile> > Post([FromBody] string text) { var bearerToken = Request.Headers["Authorization"]; _logger.LogInformation($"Post: {bearerToken} {DateTime.Now}"); var textFile = await _textService.AddFileAsync(text); return(new OkObjectResult(textFile)); }
public async Task AddFileAsyncShouldExecuteRepositoryCreateAsync() { // Arrange var testString = "Quod equidem non reprehendo;"; var val = Guid.NewGuid(); var textEntity = new TextEntity { Id = val, TextValue = testString }; var textFile = new TextFile() { Id = val, TextValue = testString }; _textRepository.Setup(x => x.CreateAsync(It.IsAny <TextEntity>())).ReturnsAsync(textEntity); _mapper.Setup(m => m.Map <TextFile>(It.IsAny <TextEntity>())).Returns(textFile); // Act var result = await _textService.AddFileAsync(testString); // Assert Assert.NotNull(result); Assert.IsType <TextFile>(result); Assert.Equal(textFile.TextValue, result.TextValue); }
public async Task <ActionResult <TextFile> > Post([FromBody] string text) { var textFile = await _textService.AddFileAsync(text); return(new OkObjectResult(textFile)); }