public void EditSection_returns_EditSection_page_when_appropriate_course_and_section_found()
        {
            // Given
            A.CallTo(() => courseDataService.GetCourseDetailsFilteredByCategory(A <int> ._, A <int> ._, A <int> ._))
            .Returns(CourseDetailsTestHelper.GetDefaultCourseDetails());
            A.CallTo(() => sectionService.GetSectionAndTutorialsBySectionIdForCustomisation(A <int> ._, A <int> ._))
            .Returns(new Section(1, "Section", new List <Tutorial>()));

            // When
            var result = controller.EditSection(1, 1);

            // Then
            result.Should().BeViewResult().WithDefaultViewName().ModelAs <EditCourseSectionViewModel>();
        }
        public void EditSection_returns_NotFound_when_no_matching_section_found()
        {
            // Given
            A.CallTo(() => courseDataService.GetCourseDetailsFilteredByCategory(A <int> ._, A <int> ._, A <int> ._))
            .Returns(CourseDetailsTestHelper.GetDefaultCourseDetails());
            A.CallTo(() => sectionService.GetSectionAndTutorialsBySectionIdForCustomisation(A <int> ._, A <int> ._))
            .Returns(null);

            // When
            var result = controller.EditSection(1, 1);

            // Then
            result.Should().BeNotFoundResult();
        }
        public void Index_returns_Index_page_when_appropriate_course_found()
        {
            // Given
            A.CallTo(() => courseDataService.GetCourseDetailsFilteredByCategory(A <int> ._, A <int> ._, A <int> ._))
            .Returns(CourseDetailsTestHelper.GetDefaultCourseDetails());
            A.CallTo(() => sectionService.GetSectionsAndTutorialsForCustomisation(A <int> ._, A <int> ._))
            .Returns(new List <Section>());

            // When
            var result = controller.Index(1);

            // Then
            result.Should().BeViewResult().WithDefaultViewName().ModelAs <CourseContentViewModel>();
        }
        public void Date_fields_should_display_in_day_month_year_order()
        {
            // Given
            var testDateTime  = new DateTime(2012, 12, 21, 22, 22, 22);
            var courseDetails = CourseDetailsTestHelper.GetDefaultCourseDetails(
                createdDate: testDateTime,
                lastAccessed: testDateTime
                );

            // When
            var viewModel = new CourseSummaryViewModel(courseDetails);

            // Then
            using (new AssertionScope())
            {
                viewModel.CreatedDate.Should().Be("21/12/2012");
                viewModel.LastAccessed.Should().Be("21/12/2012");
            }
        }
        public void Month_fields_should_display_plural_months_when_value_is_multiple_months()
        {
            // Given
            var courseDetails = CourseDetailsTestHelper.GetDefaultCourseDetails(
                autoRefreshMonths: 2,
                completeWithinMonths: 2,
                validityMonths: 2
                );

            // When
            var viewModel = new LearningPathwayDefaultsViewModel(courseDetails);

            // Then
            using (new AssertionScope())
            {
                viewModel.AutoRefreshMonths.Should().Be("2 months before expiry");
                viewModel.CompleteWithinMonths.Should().Be("2 months");
                viewModel.CompletionValidFor.Should().Be("2 months");
            }
        }
Пример #6
0
        public void GetCourseDetailsFilteredByCategory_should_return_course_details_correctly()
        {
            // Given
            const int customisationId       = 100;
            const int centreId              = 101;
            int?      categoryId            = null;
            var       fixedCreationDateTime = DateTime.UtcNow;
            var       expectedLastAccess    = new DateTime(2014, 03, 31, 13, 00, 23, 457);
            var       expectedCourseDetails = CourseDetailsTestHelper.GetDefaultCourseDetails(
                createdDate: fixedCreationDateTime,
                lastAccessed: expectedLastAccess
                );

            // When
            var result =
                courseDataService.GetCourseDetailsFilteredByCategory(customisationId, centreId, categoryId) !;

            // Overwrite the created time as it is populated by a default constraint and not consistent over different databases
            result.CreatedDate = fixedCreationDateTime;

            // Then
            result.Should().BeEquivalentTo(expectedCourseDetails);
        }