public async Task <IActionResult> UploadLeftDiff([FromBody] LeftDataViewModel leftDiff) { if (!ModelState.IsValid) { return(BadRequest()); } Guid id = await _diffAppService.SaveLeftData(leftDiff); return(Ok(id)); }
public async Task UploadLeftDiff_success() { //Arrange LeftDataViewModel fakeData = new LeftDataViewModel() { LeftData = "abcdefg" }; _diffAppServiceMock.Setup(x => x.SaveLeftData(It.IsAny <LeftDataViewModel>())) .Returns(Task.FromResult(new Guid())); //Act var diffController = new DiffController(_diffAppServiceMock.Object); diffController.ControllerContext.HttpContext = _contextMock.Object; var actionResult = await diffController.UploadLeftDiff(fakeData); //Assert Assert.Equal((actionResult as OkObjectResult).StatusCode, (int)System.Net.HttpStatusCode.OK); }
public async Task <Guid> SaveLeftData(LeftDataViewModel leftViewModel) { Diff diff = await _diffDomainService.SaveLeftData(_mapper.Map <Diff>(leftViewModel)); return(diff.Id); }