示例#1
0
        public async Task <IActionResult> UploadRightDiff([FromBody] RightDataViewModel rightDiff)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                await _diffAppService.SaveRightData(rightDiff);

                return(Ok());
            }
            catch (Exception)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }
示例#2
0
        public async Task UploadRightDiff_success()
        {
            //Arrange
            RightDataViewModel fakeData = new RightDataViewModel()
            {
                Id        = new Guid(),
                RightData = "abcdefg"
            };

            _diffAppServiceMock.Setup(x => x.SaveRightData(It.IsAny <RightDataViewModel>()))
            .Returns(Task.CompletedTask);

            //Act
            var diffController = new DiffController(_diffAppServiceMock.Object);

            diffController.ControllerContext.HttpContext = _contextMock.Object;
            var actionResult = await diffController.UploadRightDiff(fakeData);

            //Assert
            Assert.Equal((actionResult as OkResult).StatusCode, (int)System.Net.HttpStatusCode.OK);
        }
示例#3
0
 public async Task SaveRightData(RightDataViewModel rightViewModel)
 {
     await _diffDomainService.SaveRightData(_mapper.Map <Diff>(rightViewModel));
 }