コード例 #1
0
ファイル: ChesControllerTest.cs プロジェクト: ychung-mot/PIMS
        public async void GetStatusAsync_Post_Success()
        {
            // Arrange
            var helper     = new TestHelper();
            var controller = helper.CreateController <ChesController>(Permissions.PropertyEdit);

            var filter   = new Model.StatusModel();
            var response = new[] {
                new Model.StatusResponseModel()
                {
                    TransactionId = Guid.NewGuid(),
                    MessageId     = Guid.NewGuid(),
                    CreatedOn     = DateTime.UtcNow,
                    Status        = "pending",
                    SendOn        = DateTime.UtcNow
                }
            };

            var service = helper.GetService <Mock <IChesService> >();

            service.Setup(m => m.GetStatusAsync(It.IsAny <Model.StatusModel>())).ReturnsAsync(response);

            // Act
            var result = await controller.GetStatusAsync(filter);

            // Assert
            JsonResult actionResult = Assert.IsType <JsonResult>(result);
            var        results      = Assert.IsAssignableFrom <IEnumerable <Model.StatusResponseModel> >(actionResult.Value);
        }
コード例 #2
0
        public async Task <IActionResult> GetStatusAsync([FromQuery] Model.StatusModel filter)
        {
            var result = await _chesService.GetStatusAsync(filter);

            return(new JsonResult(result));
        }