public async Task And_Exception_Then_Returns_Bad_Request( [Frozen] Mock <IMediator> mockMediator, [Greedy] ReferenceDataController controller) { mockMediator .Setup(mediator => mediator.Send( It.IsAny <GetCandidateSkillsQuery>(), It.IsAny <CancellationToken>())) .ThrowsAsync(new InvalidOperationException()); var controllerResult = await controller.GetSkills() as StatusCodeResult; controllerResult.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError); }
public async Task Then_Gets_Skills_From_Mediator( GetCandidateSkillsQueryResponse mediatorResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] ReferenceDataController controller) { mockMediator .Setup(mediator => mediator.Send( It.IsAny <GetCandidateSkillsQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(mediatorResult); var controllerResult = await controller.GetSkills() as ObjectResult; Assert.IsNotNull(controllerResult); controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var model = controllerResult.Value as GetCandidateSkillsListResponse; Assert.IsNotNull(model); model.CandidateSkills.Should().BeEquivalentTo(mediatorResult.CandidateSkills); }