コード例 #1
0
        public async Task Then_The_Request_Is_Passed_To_Mediator_And_Data_Returned()
        {
            _mediator.Setup(x => x.SendAsync(It.IsAny <GetAllStandardTrainingProgrammesQuery>()))
            .ReturnsAsync(_queryResult);

            var actual = await _controller.GetAllStandards() as OkNegotiatedContentResult <GetAllTrainingProgrammeStandardsResponse>;;

            //actual
            Assert.IsNotNull(actual);
            actual.Content.TrainingProgrammes.Should().BeEquivalentTo(_queryResult.TrainingProgrammes);
        }
コード例 #2
0
        public async Task Then_If_There_Is_An_Error_A_Bad_Request_Is_Returned(
            [Frozen] Mock <IMediator> mediator,
            TrainingProgrammeController controller)
        {
            mediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetAllTrainingProgrammeStandardsQuery>(),
                       It.IsAny <CancellationToken>()))
            .Throws <InvalidOperationException>();

            var controllerResult = await controller.GetAllStandards() as StatusCodeResult;

            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
        }
コード例 #3
0
        public async Task Then_The_Request_Is_Passed_To_Mediator_And_Data_Returned(
            GetAllTrainingProgrammeStandardsQueryResult result,
            [Frozen] Mock <IMediator> mediator,
            TrainingProgrammeController controller)
        {
            mediator.Setup(x => x.Send(It.IsAny <GetAllTrainingProgrammeStandardsQuery>(), CancellationToken.None)).ReturnsAsync(result);

            var actual = await controller.GetAllStandards() as OkObjectResult;;

            //actual
            Assert.IsNotNull(actual);
            var model = actual.Value as GetAllTrainingProgrammeStandardsResponse;

            Assert.IsNotNull(model);
            model.TrainingProgrammes.Should().BeEquivalentTo(result.TrainingProgrammes);
        }