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 <CourseStoppedCommand>(), It.IsAny <CancellationToken>())).ThrowsAsync(new Exception()); var controllerResult = await controller.SendCourseStoppedEmail(id, courseDemandId) as StatusCodeResult; controllerResult !.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError); }
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.SendCourseStoppedEmail(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 <CourseStoppedCommand>(command => command.Id == id && command.EmployerDemandId == courseDemandId ), It.IsAny <CancellationToken>())); }