コード例 #1
0
ファイル: DiffController.cs プロジェクト: SacuL/DifferProject
        public async Task <IActionResult> UploadLeftDiff([FromBody] LeftDataViewModel leftDiff)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            Guid id = await _diffAppService.SaveLeftData(leftDiff);

            return(Ok(id));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: DiffAppService.cs プロジェクト: SacuL/DifferProject
        public async Task <Guid> SaveLeftData(LeftDataViewModel leftViewModel)
        {
            Diff diff = await _diffDomainService.SaveLeftData(_mapper.Map <Diff>(leftViewModel));

            return(diff.Id);
        }