예제 #1
0
        public async Task Then_If_There_Is_An_Error_A_Bad_Request_Is_Returned(
            Guid id,
            Guid courseDemandId,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] DemandController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <SendAutomaticEmployerDemandDemandCutOffCommand>(),
                       It.IsAny <CancellationToken>())).ThrowsAsync(new Exception());

            var controllerResult = await controller.SendAutomaticCutOffEmail(id, courseDemandId) as StatusCodeResult;

            controllerResult !.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError);
        }
예제 #2
0
        public async Task Then_The_Command_Is_Processed_By_Mediator_And_Id_Returned(
            Guid id,
            Guid courseDemandId,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] DemandController controller)
        {
            //Act
            var controllerResult = await controller.SendAutomaticCutOffEmail(courseDemandId, id) as CreatedResult;

            //Assert
            controllerResult !.StatusCode.Should().Be((int)HttpStatusCode.Created);
            controllerResult.Value.Should().BeEquivalentTo(new { id });
            mockMediator
            .Verify(mediator => mediator.Send(
                        It.Is <SendAutomaticEmployerDemandDemandCutOffCommand>(command =>
                                                                               command.Id == id &&
                                                                               command.EmployerDemandId == courseDemandId
                                                                               ),
                        It.IsAny <CancellationToken>()));
        }