Пример #1
0
        public async Task Then_Mediator_Is_Called_And_The_ViewModel_Returned_And_FAT_Url_Taken_From_Config(
            int courseId,
            Guid demandId,
            GetCachedCreateCourseDemandQueryResult mediatorResult,
            [Frozen] Mock <IOptions <Domain.Configuration.EmployerDemand> > config,
            [Frozen] Mock <IMediator> mediator,
            [Greedy] RegisterDemandController controller)
        {
            //Arrange
            mediator.Setup(x =>
                           x.Send(It.Is <GetCachedCreateCourseDemandQuery>(c =>
                                                                           c.Id.Equals(demandId))
                                  , It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            //Act
            var actual = await controller.RegisterDemandCompleted(courseId, demandId) as ViewResult;

            //Assert
            Assert.IsNotNull(actual);
            var actualModel = actual.Model as CompletedCourseDemandViewModel;

            Assert.IsNotNull(actualModel);
            actualModel.TrainingCourse.Should().BeEquivalentTo(mediatorResult.CourseDemand.Course);
            actualModel.FindApprenticeshipTrainingCourseUrl.Should().Be(config.Object.Value.FindApprenticeshipTrainingUrl + "/courses");
        }
Пример #2
0
        public async Task Then_If_The_Cached_Object_Is_Null_Then_Redirect_To_EnterApprenticeshipDetails(
            int courseId,
            Guid demandId,
            GetCachedCreateCourseDemandQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mediator,
            [Greedy] RegisterDemandController controller)
        {
            //Arrange
            mediatorResult.CourseDemand = null;
            mediator.Setup(x =>
                           x.Send(It.Is <GetCachedCreateCourseDemandQuery>(c =>
                                                                           c.Id.Equals(demandId))
                                  , It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            //Act
            var actual = await controller.RegisterDemandCompleted(courseId, demandId) as RedirectToRouteResult;

            //Assert
            Assert.IsNotNull(actual);

            actual.RouteName.Should().Be(RouteNames.RegisterDemand);
            actual.RouteValues.ContainsKey("Id").Should().BeTrue();
            actual.RouteValues["Id"].Should().Be(courseId);
        }
        public async Task Then_Mediator_Is_Called_And_The_ViewModel_Returned(
            int courseId,
            Guid demandId,
            GetCachedCreateCourseDemandQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mediator,
            [Greedy] RegisterDemandController controller)
        {
            //Arrange
            mediator.Setup(x =>
                           x.Send(It.Is <GetCachedCreateCourseDemandQuery>(c =>
                                                                           c.Id.Equals(demandId))
                                  , It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            //Act
            var actual = await controller.ConfirmRegisterDemand(courseId, demandId) as ViewResult;

            //Assert
            Assert.IsNotNull(actual);
            var actualModel = actual.Model as ConfirmCourseDemandViewModel;

            Assert.IsNotNull(actualModel);
            actualModel.TrainingCourse.Should().BeEquivalentTo(mediatorResult.CourseDemand.Course);
        }