示例#1
0
        public void FindsMatchingDuplicateVenues() // seen in dev data
        {
            var potentialMatch = new VenueBuilder()
                                 .WithLatitude(60)  // fixed value to avoid randomly matching
                                 .WithLongitude(-1) // fixed value to avoid randomly matching
                                 .Build();

            var duplicateMatch = VenueCloner.CloneVenue(potentialMatch);

            var availableVenues = new List <Venue>
            {
                new VenueBuilder().Build(), // decoy venue to make sure it doesn't pick the wrong one
                potentialMatch,
                duplicateMatch,
            };

            var locationVenueName = potentialMatch.VenueName;
            var locationAddress   = new ApprenticeshipLocationAddress
            {
                Address1  = potentialMatch.AddressLine1,
                Address2  = potentialMatch.AddressLine2,
                Town      = potentialMatch.Town,
                County    = potentialMatch.County,
                Postcode  = potentialMatch.Postcode,
                Latitude  = potentialMatch.Latitude,
                Longitude = potentialMatch.Longitude,
                Email     = potentialMatch.Email,
                Phone     = potentialMatch.PHONE,
                Website   = potentialMatch.Website,
            };
            var location = new ApprenticeshipLocation
            {
                VenueId      = Guid.Empty,
                RecordStatus = (int)ApprenticeshipStatus.Live,
                Name         = locationVenueName,
                Address      = locationAddress,
            };

            // act
            var matchingVenues = new VenueCorrectionFinder().GetMatchingVenues(location, availableVenues);

            matchingVenues.Should().BeEquivalentTo(duplicateMatch, potentialMatch);
        }
示例#2
0
        private static void TestVenueMatch(string locationVenueName, ApprenticeshipLocationAddress locationAddress,
                                           Guid?originalVenueGuid, Venue potentialMatch, bool expectVenueCorrection, string reason)
        {
            var availableVenues = new List <Venue>
            {
                new VenueBuilder().Build(), // decoy venue to make sure it doesn't pick the wrong one
            };

            if (potentialMatch != null)
            {
                availableVenues.Add(potentialMatch);
            }

            availableVenues.Add(new VenueBuilder().Build()); // another decoy venue to make sure it doesn't pick the wrong one

            var location = new ApprenticeshipLocation
            {
                VenueId      = originalVenueGuid,
                RecordStatus = (int)ApprenticeshipStatus.Live,
                Name         = locationVenueName,
                Address      = locationAddress,
            };

            // act
            var matchingVenues = new VenueCorrectionFinder().GetMatchingVenues(location, availableVenues);

            // assert
            if (expectVenueCorrection)
            {
                var matchingVenue = matchingVenues.Should().ContainSingle().Subject;
                matchingVenue.Should().Be(potentialMatch, reason);
            }
            else
            {
                matchingVenues.Should().BeEmpty(reason);
            }
        }