public async Task And_Then_No_Standard_Is_Returned_From_Mediator( string courseCode, [Greedy] TrainingCoursesController controller) { var controllerResult = await controller.GetStandard(courseCode) as NotFoundResult; controllerResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound); }
public async Task And_Exception_Then_Returns_Bad_Request( string courseCode, [Frozen] Mock <IMediator> mockMediator, [Greedy] TrainingCoursesController controller) { mockMediator .Setup(mediator => mediator.Send( It.IsAny <GetStandardQuery>(), It.IsAny <CancellationToken>())) .Throws <InvalidOperationException>(); var controllerResult = await controller.GetStandard(courseCode) as BadRequestResult; controllerResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); }
public async Task Then_Gets_Standard_From_Mediator( string courseCode, GetStandardsListItem mediatorResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] TrainingCoursesController controller) { mockMediator .Setup(mediator => mediator.Send( It.Is <GetStandardQuery>(x => x.CourseCode == courseCode), It.IsAny <CancellationToken>())) .ReturnsAsync(mediatorResult); var controllerResult = await controller.GetStandard(courseCode) as ObjectResult; Assert.IsNotNull(controllerResult); controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var model = controllerResult.Value as GetStandardResponse; Assert.IsNotNull(model); model.Should().BeEquivalentTo((GetStandardResponse)mediatorResult); }