コード例 #1
0
        public async void Update_NotFound()
        {
            ReleaseControllerMockFacade mock = new ReleaseControllerMockFacade();
            var mockResult = new Mock <UpdateResponse <ApiReleaseResponseModel> >();

            mockResult.SetupGet(x => x.Success).Returns(false);
            mock.ServiceMock.Setup(x => x.Update(It.IsAny <string>(), It.IsAny <ApiReleaseRequestModel>())).Returns(Task.FromResult <UpdateResponse <ApiReleaseResponseModel> >(mockResult.Object));
            mock.ServiceMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult <ApiReleaseResponseModel>(null));
            ReleaseController controller = new ReleaseController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiReleaseModelMapper());

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Update(default(string), new ApiReleaseRequestModel());

            response.Should().BeOfType <StatusCodeResult>();
            (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound);
            mock.ServiceMock.Verify(x => x.Get(It.IsAny <string>()));
        }