public async Task Then_Gets_Course_Epao_From_Mediator( int courseId, string epaoId, GetCourseEpaoResult mediatorResult, [Frozen] Mock <IMediator> mockMediator, [Greedy] CoursesController controller) { mockMediator .Setup(mediator => mediator.Send( It.Is <GetCourseEpaoQuery>(query => query.CourseId == courseId && query.EpaoId == epaoId), It.IsAny <CancellationToken>())) .ReturnsAsync(mediatorResult); var controllerResult = await controller.CourseEpao(courseId, epaoId) as ObjectResult; controllerResult !.StatusCode.Should().Be((int)HttpStatusCode.OK); var model = controllerResult.Value as GetCourseEpaoResponse; model !.Course.Should().BeEquivalentTo((GetCourseListItem)mediatorResult.Course); model !.Epao.Should().BeEquivalentTo((EpaoDetails)mediatorResult.Epao); model !.CourseEpaosCount.Should().Be(mediatorResult.CourseEpaosCount); model !.EpaoDeliveryAreas.Should().BeEquivalentTo( mediatorResult.EpaoDeliveryAreas.Select(area => (EpaoDeliveryArea)area)); model !.DeliveryAreas.Should().BeEquivalentTo( mediatorResult.DeliveryAreas.Select(item => (GetDeliveryAreaListItem)item)); model !.EffectiveFrom.Should().Be(mediatorResult.EffectiveFrom); model !.AllCourses.Should().BeEquivalentTo( mediatorResult.AllCourses.Select(item => (GetCourseListItem)item)); }
public async Task Then_Gets_CourseEpao_From_Handler( GetCourseEpaoDetailsRequest getRequest, GetCourseEpaoResult mediatorResult, [Frozen] Mock <IMediator> mockMediator, [Frozen] Mock <ILocationStringBuilder> mockLocationStringBuilder, [Greedy] CoursesController controller) { mockMediator .Setup(mediator => mediator.Send( It.Is <GetCourseEpaoQuery>(query => query.CourseId == getRequest.Id && query.EpaoId == getRequest.EpaoId), It.IsAny <CancellationToken>())) .ReturnsAsync(mediatorResult); var result = await controller.CourseEpao(getRequest) as ViewResult; var model = result !.Model as CourseEpaoViewModel; model !.Course.Should().BeEquivalentTo((CourseListItemViewModel)mediatorResult.Course); model !.CourseEpaosCount.Should().Be(mediatorResult.CourseEpaosCount); model !.Epao.Should().BeEquivalentTo(new EpaoDetailsViewModel( mediatorResult.Epao, mediatorResult.EpaoDeliveryAreas, mediatorResult.DeliveryAreas, mockLocationStringBuilder.Object.BuildLocationString )); model !.EffectiveFrom.Should().Be(mediatorResult.EffectiveFrom); model !.AllCourses.Should().BeEquivalentTo( mediatorResult.AllCourses.Select(item => (CourseListItemViewModel)item)); }