コード例 #1
0
        public async Task CalculateDiff_success()
        {
            //Arrange
            Guid fakeGuid = new Guid();
            DiffRequestViewModel fakeData = new DiffRequestViewModel()
            {
                Id = fakeGuid
            };
            DiffViewModel fakeViewModel = GetDiffViewModelFake(fakeGuid);

            _diffAppServiceMock.Setup(x => x.CalculateDiff(It.IsAny <Guid>()))
            .Returns(Task.FromResult(fakeViewModel));

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

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

            //Assert
            Assert.Equal((actionResult as OkObjectResult).StatusCode, (int)System.Net.HttpStatusCode.OK);
            Assert.Equal((((ObjectResult)actionResult).Value as DiffViewModel).Id, fakeGuid);
        }