コード例 #1
0
        public async Task Then_InternalServerError_Returned_If_An_Exception_Is_Thrown(
            [Frozen] Mock <IMediator> mediator,
            [Greedy] DemandController controller)
        {
            //Arrange
            mediator.Setup(x => x.Send(It.IsAny <GetCourseDemandsOlderThan3YearsQuery>(), CancellationToken.None))
            .ThrowsAsync(new Exception());

            //Act
            var actual = await controller.CourseDemandsOlderThan3Years() as StatusCodeResult;

            //Assert
            Assert.IsNotNull(actual);
            actual.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError);
        }
コード例 #2
0
        public async Task Then_The_Demands_Are_Returned_From_Mediator(
            GetCourseDemandsOlderThan3YearsResult queryResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] DemandController controller)
        {
            //Arrange
            mockMediator
            .Setup(x => x.Send(It.IsAny <GetCourseDemandsOlderThan3YearsQuery>(), CancellationToken.None))
            .ReturnsAsync(queryResult);

            //Act
            var actual = await controller.CourseDemandsOlderThan3Years() as ObjectResult;

            //Assert
            Assert.IsNotNull(actual);
            actual.StatusCode.Should().Be((int)HttpStatusCode.OK);
            actual.Value.Should().BeEquivalentTo(new{ queryResult.EmployerDemandIds });
        }