public void MapInto(ref CourseEnrichmentModel enrichmentModel)
        {
            var courseLength = CourseLength.HasValue ? CourseLength.Value.ToString() : null;

            enrichmentModel.CourseLength  = courseLength == "Other" ? (string.IsNullOrEmpty(CourseLengthInput) ? null : CourseLengthInput) : courseLength;
            enrichmentModel.SalaryDetails = SalaryDetails;
        }
        public IEnumerable <CopiedField> CopyFrom(CourseEnrichmentModel model)
        {
            var res = new List <CopiedField>();

            if (model == null)
            {
                return(res);
            }

            if (!string.IsNullOrWhiteSpace(model.AboutCourse))
            {
                AboutCourse = model.AboutCourse;
                res.Add(new CopiedField(nameof(model.AboutCourse), CourseEnrichmentFieldNames.AboutCourse));
            }

            if (!string.IsNullOrWhiteSpace(model.InterviewProcess))
            {
                InterviewProcess = model.InterviewProcess;
                res.Add(new CopiedField(nameof(model.InterviewProcess), CourseEnrichmentFieldNames.InterviewProcess));
            }

            if (!string.IsNullOrWhiteSpace(model.HowSchoolPlacementsWork))
            {
                HowSchoolPlacementsWork = model.HowSchoolPlacementsWork;
                res.Add(new CopiedField(nameof(model.HowSchoolPlacementsWork), CourseEnrichmentFieldNames.HowSchoolPlacementsWork));
            }

            return(res);
        }
        public IEnumerable <CopiedField> CopyFrom(CourseEnrichmentModel model)
        {
            var res = new List <CopiedField>();

            if (model == null)
            {
                return(res);
            }

            if (Enum.TryParse(model.CourseLength, out CourseLength courseLength))
            {
                CourseLength = courseLength;
                res.Add(new CopiedField(nameof(model.CourseLength), CourseEnrichmentFieldNames.CourseLength));
            }
            if (!CourseLength.HasValue && !string.IsNullOrEmpty(model.CourseLength))
            {
                CourseLengthInput = model.CourseLength;
                CourseLength      = Enums.CourseLength.Other;
            }
            if (!string.IsNullOrEmpty(model.SalaryDetails))
            {
                SalaryDetails = model.SalaryDetails;
                res.Add(new CopiedField(nameof(model.SalaryDetails), CourseEnrichmentFieldNames.SalaryDetails));
            }

            return(res);
        }
        public IEnumerable <CopiedField> CopyFrom(CourseEnrichmentModel model)
        {
            var res = new List <CopiedField>();

            if (model == null)
            {
                return(res);
            }

            if (!string.IsNullOrEmpty(model.Qualifications))
            {
                Qualifications = model.Qualifications;
                res.Add(new CopiedField(nameof(model.Qualifications), CourseEnrichmentFieldNames.Qualifications));
            }

            if (!string.IsNullOrEmpty(model.PersonalQualities))
            {
                PersonalQualities = model.PersonalQualities;
                res.Add(new CopiedField(nameof(model.PersonalQualities), CourseEnrichmentFieldNames.PersonalQualities));
            }

            if (!string.IsNullOrEmpty(model.OtherRequirements))
            {
                OtherRequirements = model.OtherRequirements;
                res.Add(new CopiedField(nameof(model.OtherRequirements), CourseEnrichmentFieldNames.OtherRequirements));
            }

            return(res);
        }
Example #5
0
        public void PublishEnrichedCourseWithEmailHappyPathTest()
        {
            var      email    = "*****@*****.**";
            Provider provider = new Provider
            {
                ProviderCode      = ProviderCode,
                AccreditedCourses =
                    new List <Course> {
                    new Course {
                        CourseCode = CourseCode, ProgramType = "SD", Name = "History"
                    }
                }
            };

            _dataServiceMock.Setup(x => x.GetProviderForUser(email, ProviderCode)).Returns(provider);
            _dataServiceMock.Setup(x => x.GetCourseForUser(email, ProviderCode, CourseCode))
            .Returns(BuildCourse(provider));

            _dataServiceMock.Setup(x => x.GetCoursesForUser(email, ProviderCode))
            .Returns(new List <Course> {
                new Course {
                    CourseCode = CourseCode, Provider = provider, ProgramType = "SD", CourseSubjects = new List <CourseSubject> {
                        new CourseSubject {
                            Subject = new Subject {
                                SubjectName = "History"
                            }
                        }
                    }, Name = "History"
                }
            });

            _enrichmentServiceMock.Setup(x => x.GetProviderEnrichmentForPublish(ProviderCode, email))
            .Returns(new UcasProviderEnrichmentGetModel {
                EnrichmentModel = new ProviderEnrichmentModel()
            });

            var enrichmentModel = new CourseEnrichmentModel {
                FeeDetails = "It's gonna cost you", FeeInternational = (Decimal)123.5, FeeUkEu = (Decimal)234.5
            };

            _enrichmentServiceMock.Setup(x => x.GetCourseEnrichmentForPublish(ProviderCode, CourseCode, email))
            .Returns(new UcasCourseEnrichmentGetModel {
                CourseCode = CourseCode, ProviderCode = ProviderCode, EnrichmentModel = enrichmentModel, Status = EnumStatus.Published
            });
            _httpMock.Setup(x => x.PutAsync(It.Is <Uri>(y => y.AbsoluteUri == $"{sncUrl}/courses"), It.IsAny <StringContent>())).ReturnsAsync(
                new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK
            }
                ).Verifiable();

            var result = _searchAndCompareService.SaveCourse(ProviderCode, CourseCode, email).Result;

            result.Should().BeTrue();
            _httpMock.VerifyAll();
        }
Example #6
0
        public void ShowPublish()
        {
            var enrichmentModel = new CourseEnrichmentModel
            {
                AboutCourse             = "AboutCourse",
                InterviewProcess        = "InterviewProcess",
                HowSchoolPlacementsWork = "HowSchoolPlacementsWork"
            };

            var ucasCourseEnrichmentGetModel = new UcasCourseEnrichmentGetModel {
                EnrichmentModel = enrichmentModel
            };

            var mockApi = new Mock <IManageApi>();

            mockApi.Setup(x => x.GetCourseEnrichment(TestHelper.ProviderCode, TestHelper.TargetedProviderCode)).ReturnsAsync(ucasCourseEnrichmentGetModel).Verifiable();
            mockApi.Setup(x => x.PublishCourseToSearchAndCompare(TestHelper.ProviderCode, TestHelper.TargetedProviderCode)).ReturnsAsync(true).Verifiable();

            mockApi.Setup(x => x.GetCourse(TestHelper.ProviderCode, TestHelper.TargetedProviderCode)).ReturnsAsync(new Course {
                ProgramType = "", Provider = new GovUk.Education.ManageCourses.Domain.Models.Provider()
            }).Verifiable();

            var objectValidator = new Mock <IObjectModelValidator>();
            BaseCourseEnrichmentViewModel objectToVerify = null;

            objectValidator.Setup(o => o.Validate(It.IsAny <ActionContext>(),
                                                  It.IsAny <ValidationStateDictionary>(),
                                                  It.IsAny <string>(),
                                                  It.IsAny <Object>()))
            .Callback <ActionContext, ValidationStateDictionary, string, Object>((a, b, c, d) =>
            {
                objectToVerify = d as BaseCourseEnrichmentViewModel;
            })
            .Verifiable();

            var frontendUrlMock  = new Mock <IFrontendUrlService>();
            var courseController = new CourseController(mockApi.Object, new Mock <ISearchAndCompareUrlService>().Object, frontendUrlMock.Object);

            courseController.ObjectValidator = objectValidator.Object;
            courseController.TempData        = new TempDataDictionary(new DefaultHttpContext(), Mock.Of <ITempDataProvider>());

            var res = courseController.ShowPublish(TestHelper.ProviderCode, "def", TestHelper.TargetedProviderCode).Result;

            mockApi.VerifyAll();
            objectValidator.VerifyAll();

            Assert.AreEqual("success", courseController.TempData["MessageType"]);
            Assert.AreEqual("Your course has been published", courseController.TempData["MessageTitle"]);

            Assert.IsNotNull(objectToVerify);
            Assert.AreEqual("AboutCourse", objectToVerify.AboutCourse);
            Assert.AreEqual("InterviewProcess", objectToVerify.InterviewProcess);
            Assert.AreEqual("HowSchoolPlacementsWork", objectToVerify.HowSchoolPlacementsWork);
        }
        public void MapInto(ref CourseEnrichmentModel enrichmentModel)
        {
            var courseLength = CourseLength.HasValue ? CourseLength.Value.ToString() : null;

            enrichmentModel.CourseLength = courseLength == "Other" ? (string.IsNullOrEmpty(CourseLengthInput) ? null : CourseLengthInput) : courseLength;

            enrichmentModel.FeeUkEu          = FeeUkEu;
            enrichmentModel.FeeInternational = FeeInternational;
            enrichmentModel.FeeDetails       = FeeDetails;
            enrichmentModel.FinancialSupport = FinancialSupport;
        }
        public void TestCourseLength1EdgeCases(string courseLength)
        {
            var enrichmentModel = new CourseEnrichmentModel {
                CourseLength = courseLength
            };

            var courseLengthResult      = enrichmentModel.CourseLength.GetCourseLength();
            var courseLengthOtherResult = enrichmentModel.CourseLength.GetCourseLengthInput();

            courseLengthResult.Should().BeNull();
            courseLengthOtherResult.Should().BeNullOrEmpty();
        }
        public void TestCourseLengthTwoYearHappyPath()
        {
            var enrichmentModel = new CourseEnrichmentModel {
                CourseLength = "TwoYears"
            };

            var courseLengthResult      = enrichmentModel.CourseLength.GetCourseLength();
            var courseLengthOtherResult = enrichmentModel.CourseLength.GetCourseLengthInput();

            courseLengthResult.Should().BeEquivalentTo(CourseLength.TwoYears);
            courseLengthOtherResult.Should().BeNullOrEmpty();
        }
        public void TestCourseLengthOtherHappyPath()
        {
            var enrichmentModel = new CourseEnrichmentModel {
                CourseLength = OtherUserEnteredText
            };

            var courseLengthResult      = enrichmentModel.CourseLength.GetCourseLength();
            var courseLengthOtherResult = enrichmentModel.CourseLength.GetCourseLengthInput();

            courseLengthResult.Should().BeEquivalentTo(CourseLength.Other);
            courseLengthOtherResult.Should().BeEquivalentTo(OtherUserEnteredText);
        }
        public void TestCourseLengthTwoYearsCopyFrom_CourseSalaryEnrichmentViewModel()
        {
            var viewModel       = new CourseSalaryEnrichmentViewModel();
            var enrichmentModel = new CourseEnrichmentModel {
                CourseLength = "TwoYears"
            };

            viewModel.CopyFrom(enrichmentModel);

            viewModel.CourseLength.Should().Be(CourseLength.TwoYears);
            viewModel.CourseLengthInput.Should().BeNullOrEmpty();
        }
        public void Test_SaveCourseEnrichment_should__argument_exception(string instCode, string email)
        {
            const string aboutCourseText = "About Course Text";

            var enrichmentService = new EnrichmentService(Context);
            var model             = new CourseEnrichmentModel
            {
                AboutCourse = aboutCourseText,
            };

            Assert.Throws <ArgumentException>(() => enrichmentService.SaveCourseEnrichment(model, instCode, UcasCourseCode, email));
        }
        public void TestCourseLengthOneYearCopyFrom_CourseFeesEnrichmentViewModel()
        {
            var viewModel       = new CourseFeesEnrichmentViewModel();
            var enrichmentModel = new CourseEnrichmentModel {
                CourseLength = "OneYear"
            };

            viewModel.CopyFrom(enrichmentModel);

            viewModel.CourseLength.Should().Be(CourseLength.OneYear);
            viewModel.CourseLengthInput.Should().BeNullOrEmpty();
        }
Example #14
0
        public async Task FeesPost()
        {
            var manageApi = new Mock <IManageApi>();

            var viewModel = new CourseFeesEnrichmentViewModel {
                FeeUkEu = 123, FeeInternational = 543, FeeDetails = "FeeDetails", CourseLength = CourseLength.TwoYears, FinancialSupport = "FinancialSupport"
            };

            var enrichmentModel = new CourseEnrichmentModel {
                FeeUkEu = 123.45m, FeeInternational = 543.21m, FeeDetails = "FeeDetails", CourseLength = null, FinancialSupport = "FinancialSupport"
            };

            var ucasCourseEnrichmentGetModel = new UcasCourseEnrichmentGetModel {
                EnrichmentModel = enrichmentModel
            };

            manageApi.Setup(x => x.GetCourseEnrichment(TestHelper.ProviderCode, TestHelper.TargetedProviderCode)).ReturnsAsync(ucasCourseEnrichmentGetModel);

            var tempDataMock  = new Mock <ITempDataDictionary>();
            var urlHelperMock = new Mock <IUrlHelper>();

            var previewLink = "preview-link";

            Expression <Func <IUrlHelper, string> > urlSetup = url => url.Action(It.Is <UrlActionContext>(uac => uac.Action == "Preview"));

            urlHelperMock.Setup(urlSetup).Returns(previewLink);

            var frontendUrlMock = new Mock <IFrontendUrlService>();
            var controller      = new CourseController(manageApi.Object, new SearchAndCompareUrlService("http://www.example.com"), frontendUrlMock.Object);

            controller.TempData = tempDataMock.Object;
            controller.Url      = urlHelperMock.Object;

            var result = await controller.FeesPost(TestHelper.ProviderCode, TestHelper.AccreditingProviderCode, TestHelper.TargetedProviderCode, viewModel);

            var redirectToActionResult = result as RedirectToActionResult;

            Assert.IsNotNull(redirectToActionResult);
            Assert.AreEqual("Show", redirectToActionResult.ActionName);

            var tempData = controller.TempData;

            VerifyTempDataIsSet(tempDataMock, previewLink);

            var routeValues = redirectToActionResult.RouteValues;

            Assert.AreEqual(TestHelper.ProviderCode, routeValues["providerCode"]);
            Assert.AreEqual(TestHelper.AccreditingProviderCode, routeValues["accreditingProviderCode"]);
            Assert.AreEqual(TestHelper.TargetedProviderCode, routeValues["courseCode"]);

            manageApi.Verify(x => x.SaveCourseEnrichment(TestHelper.ProviderCode, TestHelper.TargetedProviderCode, It.Is <CourseEnrichmentModel>(c => Check(c, viewModel))), Times.Once());
        }
Example #15
0
        public async Task RequirementsPost()
        {
            var manageApi = new Mock <IManageApi>();

            var viewModel = new CourseRequirementsEnrichmentViewModel {
                Qualifications = "Qualifications", PersonalQualities = "PersonalQualities", OtherRequirements = "OtherRequirements"
            };

            var enrichmentModel = new CourseEnrichmentModel {
                Qualifications = "", PersonalQualities = "", OtherRequirements = ""
            };
            var ucasCourseEnrichmentGetModel = new UcasCourseEnrichmentGetModel {
                EnrichmentModel = enrichmentModel
            };

            manageApi.Setup(x => x.GetCourseEnrichment(TestHelper.ProviderCode, TestHelper.TargetedProviderCode)).ReturnsAsync(ucasCourseEnrichmentGetModel);

            var tempDataMock  = new Mock <ITempDataDictionary>();
            var urlHelperMock = new Mock <IUrlHelper>();

            var previewLink = "preview-link";

            Expression <Func <IUrlHelper, string> > urlSetup = url => url.Action(It.Is <UrlActionContext>(uac => uac.Action == "Preview"));

            urlHelperMock.Setup(urlSetup).Returns(previewLink);

            var frontendUrlMock = new Mock <IFrontendUrlService>();
            var controller      = new CourseController(manageApi.Object, new SearchAndCompareUrlService("http://www.example.com"), frontendUrlMock.Object);

            controller.TempData = tempDataMock.Object;
            controller.Url      = urlHelperMock.Object;

            var result = await controller.RequirementsPost(TestHelper.ProviderCode, TestHelper.AccreditingProviderCode, TestHelper.TargetedProviderCode, viewModel);

            var redirectToActionResult = result as RedirectToActionResult;

            Assert.IsNotNull(redirectToActionResult);
            Assert.AreEqual("Show", redirectToActionResult.ActionName);

            var tempData = controller.TempData;

            VerifyTempDataIsSet(tempDataMock, previewLink);

            var routeValues = redirectToActionResult.RouteValues;

            Assert.AreEqual(TestHelper.ProviderCode, routeValues["providerCode"]);
            Assert.AreEqual(TestHelper.AccreditingProviderCode, routeValues["accreditingProviderCode"]);
            Assert.AreEqual(TestHelper.TargetedProviderCode, routeValues["courseCode"]);

            manageApi.Verify(x => x.SaveCourseEnrichment(TestHelper.ProviderCode, TestHelper.TargetedProviderCode, It.Is <CourseEnrichmentModel>(c => Check(c, viewModel))), Times.Once());
        }
Example #16
0
        public void CourseSalaryEnrichmentViewModel_CopyFrom()
        {
            var viewModel = new CourseSalaryEnrichmentViewModel
            {
                SalaryDetails = "VM.SalaryDetails"
            };

            CourseEnrichmentModel model = GetAnEnrichmentModel();

            viewModel.CopyFrom(model);

            viewModel.CourseLength.Should().Be(CourseLength.OneYear);
            viewModel.SalaryDetails.Should().Be("VM.SalaryDetails");
        }
        public void TestCourseLengthMapIntoForSelection_CourseFeesEnrichmentViewModel(string courseLengthOther)
        {
            var viewModel = new CourseFeesEnrichmentViewModel()
            {
                CourseLength      = CourseLength.OneYear,
                CourseLengthInput = courseLengthOther
            };

            var enrichmentModel = new CourseEnrichmentModel();

            viewModel.MapInto(ref enrichmentModel);

            enrichmentModel.CourseLength.Should().BeEquivalentTo("OneYear");
        }
        public void TestCourseLengthCopyFromForOtherTextEntry_CourseFeesEnrichmentViewModel()
        {
            const string textEnteredByUser = "******";

            var viewModel       = new CourseFeesEnrichmentViewModel();
            var enrichmentModel = new CourseEnrichmentModel {
                CourseLength = textEnteredByUser
            };

            viewModel.CopyFrom(enrichmentModel);

            viewModel.CourseLength.Should().Be(CourseLength.Other);
            viewModel.CourseLengthInput.Should().BeEquivalentTo(textEnteredByUser);
        }
        public void TestCourseLengthMapIntoForOtherTextEntry_CourseFeesEnrichmentViewModel()
        {
            const string TextEnteredByUser = "******";
            var          viewModel         = new CourseFeesEnrichmentViewModel
            {
                CourseLength      = CourseLength.Other,
                CourseLengthInput = TextEnteredByUser
            };

            var enrichmentModel = new CourseEnrichmentModel();

            viewModel.MapInto(ref enrichmentModel);

            enrichmentModel.CourseLength.Should().BeEquivalentTo(TextEnteredByUser);
        }
        public void EnrichmentDataSurvivesDeleteAndRecreate()
        {
            const string aboutCourseText = "About Course Text";
            // Arrange
            var enrichmentService = new EnrichmentService(Context);
            var dataService       = new DataService(Context, enrichmentService, new Mock <ILogger <DataService> >().Object);
            var sourceModel       = new CourseEnrichmentModel
            {
                AboutCourse = aboutCourseText,
            };

            enrichmentService.SaveCourseEnrichment(sourceModel, _ucasInstitution.ProviderCode, UcasCourseCode, Email);

            // Act
            var ucasPayload = new UcasPayload
            {
                // todo: test with change of this institution: https://trello.com/c/e1FwXuYk/133-ucas-institutions-dont-get-updated-during-ucas-import
                Institutions = new List <UcasInstitution>
                {
                    new UcasInstitution
                    {
                        InstCode = _ucasInstitution.ProviderCode,
                        InstFull = "Rebranded Provider",
                    },
                    new UcasInstitution
                    {
                        InstCode = AccreditingInstCode,
                        InstFull = "Rebranded Accrediting Provider",
                    },
                },
                Courses = new List <UcasCourse>
                {
                    new UcasCourse
                    {
                        InstCode            = _ucasInstitution.ProviderCode,
                        CrseCode            = "CC11",
                        AccreditingProvider = AccreditingInstCode,
                    },
                },
            };

            new UcasDataMigrator(Context, new Mock <Serilog.ILogger>().Object, ucasPayload).UpdateUcasData();

            // Assert
            var res = enrichmentService.GetCourseEnrichment(_ucasInstitution.ProviderCode, UcasCourseCode, Email);

            res.EnrichmentModel.AboutCourse.Should().Be(sourceModel.AboutCourse);
        }
Example #21
0
        public void CourseRequirementsEnrichmentViewModel_CopyFrom()
        {
            var viewModel = new CourseRequirementsEnrichmentViewModel
            {
                Qualifications    = "VM.Qualifications",
                PersonalQualities = "VM.PersonalQualities",
                OtherRequirements = "VM.OtherRequirements"
            };
            CourseEnrichmentModel model = GetAnEnrichmentModel();

            viewModel.CopyFrom(model);

            viewModel.Qualifications.Should().Be("M.Qualifications");
            viewModel.PersonalQualities.Should().Be("VM.PersonalQualities");
            viewModel.OtherRequirements.Should().Be("M.OtherRequirements");
        }
        public async Task CoursePublishTest()
        {
            SetupSmokeTestData();
            var apiClient = await BuildSigninAwareClient();

            const string ucasProviderCode = "ABC";
            const string ucasCourseCode   = "CC101";
            var          postModel        = new CourseEnrichmentModel
            {
                AboutCourse = "'Begin at the beginning,' the King said, very gravely, 'and go on till you come to the end: then stop.'",
            };
            await apiClient.Enrichment_SaveCourseAsync(ucasProviderCode, ucasCourseCode, postModel);

//            var result = await apiClient(ucasInstitutionCode, ucasCourseCode);
//            result.Should().BeTrue();
        }
Example #23
0
        public void AboutCourseEnrichmentViewModel_CopyFrom()
        {
            var viewModel = new AboutCourseEnrichmentViewModel
            {
                AboutCourse             = "VM.AboutCourse",
                InterviewProcess        = "VM.InterviewProcess",
                HowSchoolPlacementsWork = "VM.HowSchoolPlacementsWork"
            };
            CourseEnrichmentModel model = GetAnEnrichmentModel();

            viewModel.CopyFrom(model);

            viewModel.AboutCourse.Should().Be("M.AboutCourse");
            viewModel.InterviewProcess.Should().Be("VM.InterviewProcess");
            viewModel.HowSchoolPlacementsWork.Should().Be("M.HowSchoolPlacementsWork");
        }
Example #24
0
        private bool Check(CourseEnrichmentModel model, ICourseEnrichmentViewModel viewModel)
        {
            var result = false;
            var aboutCourseEnrichmentViewModel = viewModel as AboutCourseEnrichmentViewModel;

            if (aboutCourseEnrichmentViewModel != null)
            {
                result = aboutCourseEnrichmentViewModel.AboutCourse == model.AboutCourse &&
                         aboutCourseEnrichmentViewModel.InterviewProcess == model.InterviewProcess &&
                         aboutCourseEnrichmentViewModel.HowSchoolPlacementsWork == model.HowSchoolPlacementsWork;
            }

            var courseRequirementsEnrichmentViewModel = viewModel as CourseRequirementsEnrichmentViewModel;

            if (courseRequirementsEnrichmentViewModel != null)
            {
                result =
                    model.Qualifications == courseRequirementsEnrichmentViewModel.Qualifications &&
                    model.PersonalQualities == courseRequirementsEnrichmentViewModel.PersonalQualities &&
                    model.OtherRequirements == courseRequirementsEnrichmentViewModel.OtherRequirements;
            }

            var courseFeesEnrichmentViewModel = viewModel as CourseFeesEnrichmentViewModel;

            if (courseFeesEnrichmentViewModel != null)
            {
                var courseLength = courseFeesEnrichmentViewModel.CourseLength.HasValue ? courseFeesEnrichmentViewModel.CourseLength.Value.ToString() : null;
                result =
                    model.FeeDetails == courseFeesEnrichmentViewModel.FeeDetails &&
                    model.FeeInternational == courseFeesEnrichmentViewModel.FeeInternational &&
                    model.FeeUkEu == courseFeesEnrichmentViewModel.FeeUkEu &&
                    model.FinancialSupport == courseFeesEnrichmentViewModel.FinancialSupport &&
                    model.CourseLength == courseLength;
            }

            var courseSalaryEnrichmentViewModel = viewModel as CourseSalaryEnrichmentViewModel;

            if (courseSalaryEnrichmentViewModel != null)
            {
                var courseLength = courseSalaryEnrichmentViewModel.CourseLength.HasValue ? courseSalaryEnrichmentViewModel.CourseLength.Value.ToString() : null;
                result =
                    model.SalaryDetails == courseSalaryEnrichmentViewModel.SalaryDetails &&
                    model.CourseLength == courseLength;
            }
            return(result);
        }
        public IEnumerable <CopiedField> CopyFrom(CourseEnrichmentModel model)
        {
            var res = new List <CopiedField>();

            if (model == null)
            {
                return(res);
            }

            if (Enum.TryParse(model.CourseLength ?? "", out CourseLength courseLength))
            {
                CourseLength = courseLength;
                res.Add(new CopiedField(nameof(model.CourseLength), CourseEnrichmentFieldNames.CourseLength));
            }
            if (!CourseLength.HasValue && !string.IsNullOrEmpty(model.CourseLength))
            {
                CourseLengthInput = model.CourseLength;
                CourseLength      = Enums.CourseLength.Other;
            }
            if (model.FeeUkEu.HasValue)
            {
                FeeUkEu = model.FeeUkEu.GetFeeValue();
                res.Add(new CopiedField(nameof(model.FeeUkEu), CourseEnrichmentFieldNames.FeesUkEu));
            }

            if (model.FeeInternational.HasValue)
            {
                FeeInternational = model.FeeInternational.GetFeeValue();
                res.Add(new CopiedField(nameof(model.FeeInternational), CourseEnrichmentFieldNames.FeesInternational));
            }

            if (!string.IsNullOrEmpty(model.FeeDetails))
            {
                FeeDetails = model.FeeDetails;
                res.Add(new CopiedField(nameof(model.FeeDetails), CourseEnrichmentFieldNames.FeeDetails));
            }

            if (!string.IsNullOrEmpty(model.FinancialSupport))
            {
                FinancialSupport = model.FinancialSupport;
                res.Add(new CopiedField(nameof(model.FinancialSupport), CourseEnrichmentFieldNames.FinancialSupport));
            }

            return(res);
        }
Example #26
0
        public void CourseFeesEnrichmentViewModel_CopyFrom()
        {
            var viewModel = new CourseFeesEnrichmentViewModel
            {
                FeeInternational = 123,
                FinancialSupport = null // also empty
            };

            CourseEnrichmentModel model = GetAnEnrichmentModel();

            viewModel.CopyFrom(model);

            viewModel.CourseLength.Should().Be(CourseLength.OneYear);
            viewModel.FeeUkEu.Should().Be(321);
            viewModel.FeeInternational.Should().Be(123);
            viewModel.FeeDetails.Should().Be("M.FeeDetails");
            viewModel.FinancialSupport.Should().BeNull();
        }
        public async Task GetSearchAndCompareCourseTest()
        {
            SetupSmokeTestData();
            var apiClient = await BuildSigninAwareClient();

            const string ucasProviderCode = "ABC";
            const string ucasCourseCode   = "XYZ";
            var          postModel        = new CourseEnrichmentModel
            {
                AboutCourse = "'Begin at the beginning,' the King said, very gravely, 'and go on till you come to the end: then stop.'",
            };
            await apiClient.Enrichment_SaveCourseAsync(ucasProviderCode, ucasCourseCode, postModel);

            var result = await apiClient.Publish_GetSearchAndCompareCourseAsync(ucasProviderCode, ucasCourseCode);

            result.ProgrammeCode.Should().BeEquivalentTo(ucasCourseCode);
            result.Provider.ProviderCode.Should().BeEquivalentTo(ucasProviderCode);
        }
Example #28
0
        public void PublishEnrichedCourseWithEmailDraftTest()
        {
            var      email    = "*****@*****.**";
            Provider provider = new Provider
            {
                ProviderCode      = ProviderCode,
                AccreditedCourses =
                    new List <Course> {
                    new Course {
                        CourseCode = CourseCode, ProgramType = "SD", Name = "History"
                    }
                }
            };

            _dataServiceMock.Setup(x => x.GetProviderForUser(email, ProviderCode)).Returns(provider);
            _dataServiceMock.Setup(x => x.GetCourseForUser(email, ProviderCode, CourseCode))
            .Returns(new Course {
                CourseCode = CourseCode, Provider = provider, ProgramType = "SD", CourseSubjects = new List <CourseSubject> {
                    new CourseSubject {
                        Subject = new Subject {
                            SubjectName = "History"
                        }
                    }
                }, Name = "History"
            });

            _enrichmentServiceMock.Setup(x => x.GetProviderEnrichmentForPublish(ProviderCode, email))
            .Returns(new UcasProviderEnrichmentGetModel {
                EnrichmentModel = new ProviderEnrichmentModel()
            });

            var enrichmentModel = new CourseEnrichmentModel {
                FeeDetails = "It's gonna cost you", FeeInternational = (Decimal)123.5, FeeUkEu = (Decimal)234.5
            };

            _enrichmentServiceMock.Setup(x => x.GetCourseEnrichmentForPublish(ProviderCode, CourseCode, email))
            .Returns(new UcasCourseEnrichmentGetModel {
                CourseCode = CourseCode, ProviderCode = ProviderCode, EnrichmentModel = enrichmentModel, Status = EnumStatus.Draft
            });
            var result = _searchAndCompareService.SaveCourse(ProviderCode, CourseCode, email).Result;

            result.Should().BeFalse();
        }
        public async Task CourseEnrichmentRoundTrip()
        {
            SetupSmokeTestData();
            var apiClient = await BuildSigninAwareClient();

            const string ucasProviderCode = "ABC";
            const string ucasCourseCode   = "CC101";
            var          postModel        = new CourseEnrichmentModel
            {
                AboutCourse = "'Begin at the beginning,' the King said, very gravely, 'and go on till you come to the end: then stop.'",
            };
            await apiClient.Enrichment_SaveCourseAsync(ucasProviderCode, ucasCourseCode, postModel);

            var loadedEnrichment = await apiClient.Enrichment_GetCourseAsync(ucasProviderCode, ucasCourseCode);

            loadedEnrichment.Should().NotBeNull();
            loadedEnrichment.EnrichmentModel.Should().NotBeNull();
            loadedEnrichment.EnrichmentModel.AboutCourse.Should().Be(postModel.AboutCourse);
        }
Example #30
0
        private static CourseEnrichmentModel GetAnEnrichmentModel()
        {
            CourseEnrichmentModel model = new CourseEnrichmentModel
            {
                AboutCourse             = "M.AboutCourse",
                InterviewProcess        = "", //empty!!
                HowSchoolPlacementsWork = "M.HowSchoolPlacementsWork",

                Qualifications    = "M.Qualifications",
                PersonalQualities = "", //empty!!
                OtherRequirements = "M.OtherRequirements",

                CourseLength     = "OneYear",
                FeeUkEu          = 321,
                FeeInternational = null, //empty!!
                FeeDetails       = "M.FeeDetails",
                FinancialSupport = null, //empty!!
            };

            return(model);
        }