public void ShouldMapRoatpResultWithoutUkprnToNull()
        {
            var roatpResult  = new RoatpResult();
            var mappedResult = _mapper.Map(roatpResult);

            Assert.IsNull(mappedResult);
        }
        public void ShouldMapRoatpResultUkprnToProviderUkprn(long ukprn)
        {
            var roatpResult = new RoatpResult();

            roatpResult.Ukprn = ukprn.ToString();
            var mappedResult = _mapper.Map(roatpResult);

            Assert.AreEqual(roatpResult.Ukprn, mappedResult.Ukprn.ToString());
        }
        public void ShouldMapRoatpResultOrganisationNameToProviderName(string organisationName)
        {
            var roatpResult = new RoatpResult();

            roatpResult.Ukprn            = "12345678";
            roatpResult.OrganisationName = organisationName;
            var mappedResult = _mapper.Map(roatpResult);

            Assert.AreEqual(roatpResult.OrganisationName, mappedResult.Name);
        }
예제 #4
0
        public void ShouldThrowNotFoundIfUkprnNotMatchedOrStartDateNotTodayOrAfterForHead(string ukprnType, string startDate, int httpStatusCode)
        {
            DateTime startDateToUse;

            switch (startDate)
            {
            case "tomorrow":
                startDateToUse = DateTime.Today.AddDays(1);
                break;

            case "yesterday":
                startDateToUse = DateTime.Today.AddDays(-1);
                break;

            default:
                startDateToUse = DateTime.Today;
                break;
            }


            var roatpResult = new RoatpResult
            {
                Ukprn     = _ukprn.ToString(),
                StartDate = startDateToUse
            };

            if (ukprnType != "absentUkprn")
            {
                _mockClient.Setup(z => z.GetRoatpSummaryByUkprn(_ukprn)).ReturnsAsync(new List <RoatpResult> {
                    roatpResult
                });
            }

            var resultFromGet = _controller.Head(_ukprn).Result;

            if (httpStatusCode == (int)HttpStatusCode.NoContent)
            {
                Assert.IsTrue(((NoContentResult)resultFromGet).StatusCode == httpStatusCode);
            }
            else
            {
                Assert.IsTrue(((ObjectResult)resultFromGet).StatusCode == httpStatusCode);
            }

            if (httpStatusCode == (int)HttpStatusCode.OK)
            {
                var returnedProvider = (Provider)((ObjectResult)resultFromGet).Value;
                Assert.AreEqual(_ukprn, returnedProvider.Ukprn);
            }
            else if (httpStatusCode != (int)HttpStatusCode.NoContent)
            {
                var returnedDetails = (string)((ObjectResult)resultFromGet).Value;
                Assert.IsNotEmpty(returnedDetails);
            }
        }
        public void ShouldMapRoatpResultProviderTypeToProviderProviderType(string providerType, ProviderType expectedProviderType)
        {
            var roatpResult = new RoatpResult();

            roatpResult.Ukprn            = "12345678";
            roatpResult.OrganisationName = "org name";
            roatpResult.ProviderType     = providerType;
            var mappedResult = _mapper.Map(roatpResult);

            Assert.AreEqual(((ProviderType)expectedProviderType).ToString(), mappedResult.ProviderType.ToString());
        }
예제 #6
0
        public void ShouldMapRoatpResultProviderTypeToCSVProviderProviderType(string providerType, string expectedProviderType)
        {
            var roatpResult = new RoatpResult();

            roatpResult.Ukprn            = "12345678";
            roatpResult.OrganisationName = "org name";
            roatpResult.ProviderType     = providerType;
            var mappedResult = _mapper.MapCsv(roatpResult);

            Assert.AreEqual(expectedProviderType, mappedResult.ProviderType);
        }
        public void ShouldMapRoatpResultNewOrganisationToProviderNewOrganisation(string newOrganisationWithoutFinancialTrackRecord, bool expectedMapping)
        {
            var roatpResult = new RoatpResult();

            roatpResult.Ukprn            = "12345678";
            roatpResult.OrganisationName = "org name";
            roatpResult.ProviderType     = "main provider";
            roatpResult.NewOrganisationWithoutFinancialTrackRecord = newOrganisationWithoutFinancialTrackRecord;
            var mappedResult = _mapper.Map(roatpResult);

            Assert.AreEqual(expectedMapping, mappedResult.NewOrganisationWithoutFinancialTrackRecord);
        }
        public void ShouldMapRoatpResultParentCompanyGuaranteeToProviderParentCompanyGuarantee(string parentCompanyGuarantee, bool expectedMapping)
        {
            var roatpResult = new RoatpResult();

            roatpResult.Ukprn            = "12345678";
            roatpResult.OrganisationName = "org name";
            roatpResult.ProviderType     = "main provider";
            roatpResult.NewOrganisationWithoutFinancialTrackRecord = "Y";
            roatpResult.ParentCompanyGuarantee = parentCompanyGuarantee;
            var mappedResult = _mapper.Map(roatpResult);

            Assert.AreEqual(expectedMapping, mappedResult.ParentCompanyGuarantee);
        }
        public void ShouldMapRoatpResultStartDateToProviderStartDate(DateTime?startDate, DateTime?expectedMapping)
        {
            var roatpResult = new RoatpResult();

            roatpResult.Ukprn            = "12345678";
            roatpResult.OrganisationName = "org name";
            roatpResult.ProviderType     = "main provider";
            roatpResult.NewOrganisationWithoutFinancialTrackRecord = "Y";
            roatpResult.ParentCompanyGuarantee = "N";
            roatpResult.StartDate = startDate;
            var mappedResult = _mapper.Map(roatpResult);

            Assert.AreEqual(expectedMapping, mappedResult.StartDate);
        }
예제 #10
0
        public void ShouldMapRoatpResultApplicationDeterminedDateToCsvProviderApplicationDate(DateTime?applicationDeterminedDate, string expectedMapping)
        {
            var roatpResult = new RoatpResult();

            roatpResult.Ukprn            = "12345678";
            roatpResult.OrganisationName = "org name";
            roatpResult.ProviderType     = "main provider";
            roatpResult.NewOrganisationWithoutFinancialTrackRecord = "Y";
            roatpResult.ParentCompanyGuarantee = "N";
            roatpResult.StartDate = DateTime.Today;
            roatpResult.ApplicationDeterminedDate = applicationDeterminedDate;
            var mappedResult = _mapper.MapCsv(roatpResult);

            Assert.AreEqual(expectedMapping, mappedResult.ApplicationDeterminedDate);
        }
        public void ShouldMapRoatpResultCurrentlyNotStartingToProviderCurrentlyNotStarting(DateTime?providerNotCurrentlyStartingNewApprentices, bool expectedMapping)
        {
            var roatpResult = new RoatpResult();

            roatpResult.Ukprn            = "12345678";
            roatpResult.OrganisationName = "org name";
            roatpResult.ProviderType     = "main provider";
            roatpResult.NewOrganisationWithoutFinancialTrackRecord = "Y";
            roatpResult.ParentCompanyGuarantee = "Y";
            roatpResult.StartDate = DateTime.Today;
            roatpResult.ApplicationDeterminedDate = DateTime.Today;
            roatpResult.ProviderNotCurrentlyStartingNewApprentices = providerNotCurrentlyStartingNewApprentices;
            var mappedResult = _mapper.Map(roatpResult);

            Assert.AreEqual(expectedMapping, mappedResult.CurrentlyNotStartingNewApprentices);
        }
예제 #12
0
        public void ShouldReturnExpectedNumberOfRecordsFromGetAll(string startDate, int expectedCount)
        {
            var roatpResults = new List <RoatpResult>
            {
                new RoatpResult {
                    Ukprn = "11111111", StartDate = DateTime.Today
                }
            };

            DateTime startDateToUse;

            switch (startDate)
            {
            case "tomorrow":
                startDateToUse = DateTime.Today.AddDays(1);
                break;

            case "yesterday":
                startDateToUse = DateTime.Today.AddDays(-1);
                break;

            default:
                startDateToUse = DateTime.Today;
                break;
            }

            var roatpResult2 = new RoatpResult {
                Ukprn = "22222222", StartDate = startDateToUse
            };

            roatpResults.Add(roatpResult2);

            _mockClient.Setup(z => z.GetRoatpSummary()).ReturnsAsync(roatpResults);

            var resultsFromGet    = _controller.GetAll().Result;
            var expectedProviders = (List <Provider>)((ObjectResult)resultsFromGet).Value;

            Assert.AreEqual(expectedCount, expectedProviders.Count);
        }
        public CsvProvider MapCsv(RoatpResult result)
        {
            if (!long.TryParse(result?.Ukprn, out long ukprn))
            {
                return(null);
            }

            var csvProvider = new CsvProvider
            {
                Ukprn        = ukprn,
                Name         = result.OrganisationName,
                ProviderType = result?.ProviderType,
                NewOrganisationWithoutFinancialTrackRecord = !string.IsNullOrEmpty(result.NewOrganisationWithoutFinancialTrackRecord) && result.NewOrganisationWithoutFinancialTrackRecord.ToUpper() == "Y",
                ParentCompanyGuarantee = result.ParentCompanyGuarantee != null && result.ParentCompanyGuarantee.ToUpper() == "Y",


                StartDate = FormatDate(result?.StartDate),
                ProviderNotCurrentlyStartingNewApprentices = result.ProviderNotCurrentlyStartingNewApprentices != null ? "TRUE" : string.Empty,
                ApplicationDeterminedDate = FormatDate(result?.ApplicationDeterminedDate)
            };

            return(csvProvider);
        }
        public Provider Map(RoatpResult roatpResult)
        {
            if (!long.TryParse(roatpResult?.Ukprn, out long ukprn))
            {
                return(null);
            }

            if (roatpResult.EndDate != null && roatpResult.EndDate <= DateTime.Today)
            {
                return(null);
            }

            return(new Provider
            {
                Ukprn = ukprn,
                Name = roatpResult.OrganisationName,
                ProviderType = MapProviderType(roatpResult?.ProviderType),
                NewOrganisationWithoutFinancialTrackRecord = !string.IsNullOrEmpty(roatpResult.NewOrganisationWithoutFinancialTrackRecord) && roatpResult.NewOrganisationWithoutFinancialTrackRecord.ToUpper() == "Y",
                ParentCompanyGuarantee = roatpResult.ParentCompanyGuarantee != null && roatpResult.ParentCompanyGuarantee.ToUpper() == "Y",
                StartDate = roatpResult?.StartDate,
                ApplicationDeterminedDate = roatpResult?.ApplicationDeterminedDate,
                CurrentlyNotStartingNewApprentices = roatpResult.ProviderNotCurrentlyStartingNewApprentices != null,
            });
        }
예제 #15
0
        private static RoatpProviderResult MapSingleRecord(RoatpResult roatpResult)
        {
            ProviderType providerType;

            switch (roatpResult.ProviderType.ToLower())
            {
            case "main provider":
                providerType = ProviderType.MainProvider;
                break;

            case "employer provider":
                providerType = ProviderType.EmployerProvider;
                break;

            case "supporting provider":
                providerType = ProviderType.SupportingProvider;
                break;

            default:
                providerType = ProviderType.Unknown;
                break;
            }

            return(new RoatpProviderResult
            {
                Ukprn = roatpResult.Ukprn,
                OrganisationName = roatpResult.OrganisationName,
                ProviderType = providerType,
                ContractedForNonLeviedEmployers = roatpResult.ContractedToDeliverToNonLeviedEmployers != null && roatpResult.ContractedToDeliverToNonLeviedEmployers.ToUpper() == "Y",
                ParentCompanyGuarantee = roatpResult.ParentCompanyGuarantee != null && roatpResult.ParentCompanyGuarantee.ToUpper() == "Y",
                NewOrganisationWithoutFinancialTrackRecord = roatpResult.NewOrganisationWithoutFinancialTrackRecord != null& roatpResult.NewOrganisationWithoutFinancialTrackRecord.ToUpper() == "Y",
                StartDate = roatpResult.StartDate,
                EndDate = roatpResult.EndDate,
                NotStartingNewApprentices = roatpResult.ProviderNotCurrentlyStartingNewApprentices != null
            });
        }