public async Task CreateJsonAsync_Should_Work_Correctly(string username, JsonModel jsonModel, CreateJsonRequestDto createJsonRequestDto) { _mapper.Map <JsonModel>(createJsonRequestDto).Returns(jsonModel); _jsonService.CreateAsync(username, jsonModel).Returns(true); var response = await CreateJsonController(username).CreateJsonAsync(createJsonRequestDto); var result = response as OkResult; Assert.NotNull(result); }
public async Task <IActionResult> CreateJsonAsync([FromBody] CreateJsonRequestDto createJsonRequestDto) { if (await _jsonService.CreateAsync(User.GetUsername(), _mapper.Map <JsonModel>(createJsonRequestDto))) { return(Ok()); } return(BadRequest()); }