示例#1
0
        public Domain.Models.LocalEnterprisePartnership CreateLocalEnterprisePartnership()
        {
            var lep = new Domain.Models.LocalEnterprisePartnership
            {
                Code      = "LEP000001",
                Name      = "LEP Name",
                CreatedBy = "Sfa.Tl.Matching.Application.IntegrationTests"
            };

            _context.Add(lep);

            _context.SaveChanges();

            return(lep);
        }
        public Domain.Models.Opportunity CreateOpportunity(Guid employerCrmId, List <OpportunityItem> opportunityItems)
        {
            var opportunity = new Domain.Models.Opportunity
            {
                EmployerCrmId        = employerCrmId,
                EmployerContact      = "test",
                EmployerContactEmail = "*****@*****.**",
                EmployerContactPhone = "01234567890",
                OpportunityItem      = opportunityItems,
                CreatedBy            = "Sfa.Tl.Matching.Application.IntegrationTests",
            };

            _context.Add(opportunity);

            _context.SaveChanges();

            return(opportunity);
        }
示例#3
0
        public IList <Domain.Models.PostcodeLookup> CreatePostcodeLookup(int postcodeCount = 1)
        {
            var postcodes = new List <Domain.Models.PostcodeLookup>();

            _context.AddRange(
                Enumerable.Range(1, postcodeCount).Select(index =>
                                                          new Domain.Models.PostcodeLookup
            {
                Postcode         = $"POST PO{index}",
                PrimaryLepCode   = "LEP000001",
                SecondaryLepCode = "LEP000002",
                CreatedBy        = "Sfa.Tl.Matching.Application.IntegrationTests"
            }));

            _context.AddRange(postcodes);
            _context.SaveChanges();

            return(postcodes);
        }
示例#4
0
        internal void ResetData(string employerContact)
        {
            var opportunity = MatchingDbContext.Opportunity.FirstOrDefault(o => o.EmployerContact == employerContact);

            if (opportunity != null)
            {
                MatchingDbContext.Opportunity.Remove(opportunity);
                var count = MatchingDbContext.SaveChanges();
                count.Should().Be(1);
            }
        }
        public Domain.Models.Employer CreateEmployer(Guid crmId)
        {
            var employer = new Domain.Models.Employer
            {
                AlsoKnownAs    = "test aka",
                Aupa           = "test aupa",
                CompanyName    = "test company name",
                CrmId          = Guid.NewGuid(),
                Email          = "*****@*****.**",
                Owner          = "test owner",
                Phone          = "01234567890",
                PrimaryContact = "test contact",
                CreatedBy      = "Sfa.Tl.Matching.Application.IntegrationTests",
            };

            _context.Add(employer);
            _context.SaveChanges();

            return(employer);
        }
        public void ResetData(string lepCode = null)
        {
            if (string.IsNullOrWhiteSpace(lepCode))
            {
                MatchingDbContext.Database.ExecuteSqlRaw("DELETE FROM PostcodeLookup");
                MatchingDbContext.SaveChanges();
                return;
            }

            var postcodeLookup = MatchingDbContext.PostcodeLookup.FirstOrDefault(e => e.PrimaryLepCode == lepCode);

            if (postcodeLookup == null)
            {
                return;
            }

            MatchingDbContext.PostcodeLookup.Remove(postcodeLookup);
            var count = MatchingDbContext.SaveChanges();

            count.Should().Be(1);
        }
示例#7
0
        public void ResetData(string name = null)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                MatchingDbContext.Database.ExecuteSqlRaw("DELETE FROM LocalEnterprisePartnership");
                MatchingDbContext.SaveChanges();
                return;
            }

            var localEnterprisePartnership = MatchingDbContext.LocalEnterprisePartnership.FirstOrDefault(e => e.Name == name);

            if (localEnterprisePartnership == null)
            {
                return;
            }

            MatchingDbContext.LocalEnterprisePartnership.Remove(localEnterprisePartnership);
            var count = MatchingDbContext.SaveChanges();

            count.Should().Be(1);
        }
示例#8
0
        public void ResetData(string title = null)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                MatchingDbContext.Database.ExecuteSqlRaw("DELETE FROM LearningAimReference");
                MatchingDbContext.SaveChanges();
                return;
            }

            var learningAimReference = MatchingDbContext.LearningAimReference.FirstOrDefault(e => e.Title == title);

            if (learningAimReference == null)
            {
                return;
            }

            MatchingDbContext.LearningAimReference.Remove(learningAimReference);
            var count = MatchingDbContext.SaveChanges();

            count.Should().Be(1);
        }
        public void Dispose()
        {
            var qualificationMappings = _providerVenue.ProviderQualification.SelectMany(q => q.Qualification.QualificationRouteMapping).ToList();
            var qualifications        = _providerVenue.ProviderQualification.Select(q => q.Qualification).ToList();

            _dbContext.RemoveRange(_providerVenue.ProviderQualification);
            _dbContext.RemoveRange(_providerVenue);
            _dbContext.RemoveRange(_providerVenue.Provider);
            _dbContext.RemoveRange(qualificationMappings);
            _dbContext.RemoveRange(qualifications);

            _dbContext.SaveChanges();
            _dbContext.Dispose();
        }
示例#10
0
        public When_SqlSearchProvider_Search_Opportunities_Is_Called_With_Valid_Parameters_With_One_Venue_Enabled()
        {
            var logger = Substitute.For <ILogger <Data.SearchProviders.SqlSearchProvider> >();

            _dbContext = new TestConfiguration().GetDbContext();

            _providerVenues = new ValidProviderVenueSearchBuilder().BuildWithOneVenueEnabled();
            _dbContext.AddRange(_providerVenues);
            _dbContext.SaveChanges();

            var provider = new Data.SearchProviders.SqlSearchProvider(logger, _dbContext);

            _results = provider.SearchOpportunitiesByPostcodeProximityAsync(new OpportunityProximitySearchParametersDto {
                Postcode = "CV1 2WT", SearchRadius = 5, SelectedRouteId = 7, Latitude = "52.400997", Longitude = "-1.508122"
            }).GetAwaiter().GetResult();
        }
        public When_SqlSearchProvider_Search_Opportunities_Is_Called_With_Valid_Postcode_But_Provider_Is_Disabled_For_Selected_Route()
        {
            var logger = Substitute.For <ILogger <Data.SearchProviders.SqlSearchProvider> >();

            _dbContext = new TestConfiguration().GetDbContext();

            _providerVenue = new ValidProviderVenueSearchBuilder().BuildWithOneDisabledVenue();
            _dbContext.Add(_providerVenue);
            _dbContext.SaveChanges();

            var provider = new Data.SearchProviders.SqlSearchProvider(logger, _dbContext);

            _results = provider.SearchOpportunitiesByPostcodeProximityAsync(new OpportunityProximitySearchParametersDto {
                Postcode = "MK1 1AD", SelectedRouteId = 7, Latitude = "52.010709", Longitude = "-0.736412"
            }).GetAwaiter().GetResult();
        }
        internal static void Load(MatchingDbContext context)
        {
            context.AddRange(EmailTemplateData.Create().ToList());
            context.AddRange(EmployerData.Create().ToList());
            context.AddRange(RouteAndPathData.Create().ToList());
            context.AddRange(ProviderVenueData.Create());
            context.AddRange(OpportunityData.Create());
            context.AddRange(ServiceStatusHistoryData.Create().ToList());
            context.AddRange(LearningAimReferenceData.Create().ToList());
            context.AddRange(OpportunityData.CreateReferralSingle());
            context.AddRange(OpportunityData.CreateProvisionGapSingle());
            context.AddRange(OpportunityData.CreateReferralMultiple());
            context.AddRange(OpportunityData.CreateReferralMultipleAndProvisionGap());
            context.AddRange(OpportunityData.CreateReferralSingleAndProvisionGap());
            context.AddRange(OpportunityData.CreateProvidersMultiple());
            context.AddRange(OpportunityData.CreateNReferrals(1000));

            context.SaveChanges();
        }
        public When_SqlSearchProvider_Search_Providers_For_Report_Is_Called_With_No_Selected_Routes()
        {
            var logger = Substitute.For <ILogger <Data.SearchProviders.SqlSearchProvider> >();

            _dbContext = new TestConfiguration().GetDbContext();

            _providerVenue = new ValidProviderVenueSearchBuilder().BuildOneVenue();
            _dbContext.Add(_providerVenue);
            _dbContext.SaveChanges();

            var provider = new Data.SearchProviders.SqlSearchProvider(logger, _dbContext);

            _results = provider.SearchProvidersByPostcodeProximityForReportAsync(
                new ProviderProximitySearchParametersDto
            {
                Postcode       = "CV1 2WT",
                SearchRadius   = 5,
                SelectedRoutes = null,
                Latitude       = "52.400997",
                Longitude      = "-1.508122"
            }).GetAwaiter().GetResult();
        }
示例#14
0
        public Provider CreateProvider(int venueCount = 1)
        {
            var provider = new Provider
            {
                DisplayName           = "test provider display name",
                Name                  = "test provider",
                OfstedRating          = 1,
                PrimaryContact        = "test primary contact",
                PrimaryContactEmail   = "*****@*****.**",
                PrimaryContactPhone   = "01234567890",
                SecondaryContact      = "test secondary contact",
                SecondaryContactEmail = "*****@*****.**",
                SecondaryContactPhone = "01234567891",
                Source                = "test",
                UkPrn                 = 12345678,
                IsCdfProvider         = true,
                IsEnabledForReferral  = true,
                IsTLevelProvider      = true,
                CreatedBy             = "Sfa.Tl.Matching.Application.IntegrationTests",
                ProviderVenue         = Enumerable.Range(1, venueCount).Select(venue =>
                                                                               new ProviderVenue
                {
                    IsRemoved            = true,
                    IsEnabledForReferral = true,
                    County                = $"test county{venue}",
                    Name                  = $"test name{venue}",
                    Postcode              = $"POST PO{venue}",
                    Source                = $"test{venue}",
                    Town                  = $"test town{venue}",
                    CreatedBy             = "Sfa.Tl.Matching.Application.IntegrationTests",
                    ProviderQualification = new List <ProviderQualification>
                    {
                        new ProviderQualification
                        {
                            CreatedBy     = "Sfa.Tl.Matching.Application.IntegrationTests",
                            Source        = "test",
                            Qualification = new Qualification
                            {
                                CreatedBy  = "Sfa.Tl.Matching.Application.IntegrationTests",
                                LarId      = "12345678",
                                ShortTitle = "test short title",
                                Title      = "test title",
                                QualificationRouteMapping = new List <QualificationRouteMapping>
                                {
                                    new QualificationRouteMapping
                                    {
                                        RouteId   = 1,
                                        CreatedBy = "Sfa.Tl.Matching.Application.IntegrationTests",
                                        Source    = "test"
                                    }
                                }
                            }
                        }
                    }
                }).ToList()
            };

            _context.Add(provider);

            _context.SaveChanges();

            return(provider);
        }