public void And_No_Epao_Courses_Then_Throws_NotFoundException( GetEpaoQuery query, [Frozen] Mock <IAssessorsApiClient <AssessorsApiConfiguration> > mockAssessorsApiClient, GetEpaoQueryHandler handler) { mockAssessorsApiClient .Setup(client => client.Get <GetEpaoResponse>( It.Is <GetEpaoRequest>(request => request.EpaoId == query.EpaoId))) .ReturnsAsync(default(GetEpaoResponse)); Func <Task> act = async() => await handler.Handle(query, CancellationToken.None); act.Should().Throw <NotFoundException <GetEpaoResult> >(); }
public async Task Then_Gets_Epao_From_Assessor_Api( GetEpaoQuery query, GetEpaoResponse apiResponse, [Frozen] Mock <IAssessorsApiClient <AssessorsApiConfiguration> > mockAssessorsApiClient, GetEpaoQueryHandler handler) { mockAssessorsApiClient .Setup(client => client.Get <GetEpaoResponse>( It.Is <GetEpaoRequest>(request => request.EpaoId == query.EpaoId))) .ReturnsAsync(apiResponse); var result = await handler.Handle(query, CancellationToken.None); result.Epao.Should().BeEquivalentTo(apiResponse); }
public void And_Validation_Error_Then_Throws_ValidationException( GetEpaoQuery query, string propertyName, ValidationResult validationResult, [Frozen] Mock <IValidator <GetEpaoQuery> > mockValidator, GetEpaoQueryHandler handler) { validationResult.AddError(propertyName); mockValidator .Setup(validator => validator.ValidateAsync(It.IsAny <GetEpaoQuery>())) .ReturnsAsync(validationResult); Func <Task> act = async() => await handler.Handle(query, CancellationToken.None); act.Should().Throw <ValidationException>() .WithMessage($"*{propertyName}*"); }