Exemple #1
0
        public void LocationNullTests(string location, bool shouldBeShown)
        {
            //Arrange
            var index      = new _MVC_Views_JobProfileCourseOpportunity_Index_cshtml();
            var testCourse = new Course()
            {
                Location = location
            };
            var courses = new List <Course>
            {
                testCourse
            };

            var jobProfileApprenticeViewModel = new JobProfileCourseSearchViewModel();

            jobProfileApprenticeViewModel.Courses = courses.AsEnumerable();

            //Act
            var htmlDom = index.RenderAsHtml(jobProfileApprenticeViewModel);

            //Assert
            if (shouldBeShown)
            {
                htmlDom.DocumentNode.InnerHtml.Should().Contain($"Location:</span> {testCourse.Location}");
            }
            else
            {
                htmlDom.DocumentNode.InnerHtml.Should().NotContain($"Location:");
            }
        }
        protected override ActionResult GetEditorView()
        {
            if (CurrentJobProfile == null)
            {
                var model = new JobProfileCourseSearchViewModel
                {
                    CoursesSectionTitle    = CoursesSectionTitle,
                    NoTrainingCoursesText  = NoTrainingCoursesText,
                    TrainingCoursesText    = TrainingCoursesText,
                    CoursesLocationDetails = TrainingCoursesLocationDetails,
                    CourseLink             = CourseLink,
                    MainSectionTitle       = MainSectionTitle
                };

                return(View("Index", model));
            }

            return(GetDefaultView());
        }
        protected override ActionResult GetDefaultView()
        {
            IEnumerable <Course> trainingCourses = new List <Course>();

            if (!string.IsNullOrEmpty(CurrentJobProfile.CourseKeywords))
            {
                trainingCourses = asyncHelper.Synchronise(() => courseSearchService.GetCoursesAsync(CurrentJobProfile.CourseKeywords))?.Take(MaxTrainingCoursesMaxCount);
            }

            var model = new JobProfileCourseSearchViewModel
            {
                CoursesSectionTitle    = CoursesSectionTitle,
                NoTrainingCoursesText  = NoTrainingCoursesText.Replace("{jobtitle}", GetDynamicTitle(true)),
                TrainingCoursesText    = TrainingCoursesText.Replace("{jobtitle}", GetDynamicTitle(true)),
                CoursesLocationDetails = TrainingCoursesLocationDetails,
                CourseLink             = CourseLink,
                Courses          = trainingCourses,
                MainSectionTitle = MainSectionTitle
            };

            return(View("Index", model));
        }
Exemple #4
0
        public void StartDateNullTests(bool startDateIsNotNull)
        {
            DateTime?startDate = null;

            if (startDateIsNotNull)
            {
                startDate = DateTime.Now;
            }

            //Arrange
            var index      = new _MVC_Views_JobProfileCourseOpportunity_Index_cshtml();
            var testCourse = new Course()
            {
                StartDate = startDate
            };
            var courses = new List <Course>
            {
                testCourse
            };

            var jobProfileApprenticeViewModel = new JobProfileCourseSearchViewModel();

            jobProfileApprenticeViewModel.Courses = courses.AsEnumerable();

            //Act
            var htmlDom = index.RenderAsHtml(jobProfileApprenticeViewModel);

            //Assert
            if (startDateIsNotNull)
            {
                htmlDom.DocumentNode.InnerHtml.Should().Contain($"Start date:</span> {string.Format("{0:dd MMMM yyyy}", startDate)}");
            }
            else
            {
                htmlDom.DocumentNode.InnerHtml.Should().NotContain($"Start date:");
            }
        }