예제 #1
0
        public void TestVenueAnalyser_WithDuplicateVenues_ReturnsCorrectAnalysis()
        {
            // Arrange
            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 apprenticeshipLocation = new ApprenticeshipLocation
            {
                RecordStatus = (int)ApprenticeshipStatus.Live,
                LocationType = LocationType.Venue,
                ApprenticeshipLocationType = ApprenticeshipLocationType.ClassroomBased,
                VenueId = new Guid("F1724123-CCBA-4811-A816-128542299F87"),
                Address = AddressFromVenue(potentialMatch),
            };
            var apprenticeship = new Apprenticeship
            {
                Id = new Guid("4E75B9D5-CC97-42EE-B891-5420F84EBAE9"),
                ApprenticeshipLocations = new List <ApprenticeshipLocation> {
                    apprenticeshipLocation
                },
            };

            // Act
            var apprenticeshipVenueCorrections = _venueAnalyser.AnalyseApprenticeship(apprenticeship, availableVenues);

            // Assert
            apprenticeshipVenueCorrections.Apprenticeship.Should().Be(apprenticeship);
            apprenticeshipVenueCorrections.UnfixableVenueReason.Should().Be(null);
            var apprenticeshipLocationVenueCorrection = apprenticeshipVenueCorrections.ApprenticeshipLocationVenueCorrections.Should().ContainSingle().Subject;

            apprenticeshipLocationVenueCorrection.LocationId.Should().Be(apprenticeshipLocation.Id);
            apprenticeshipLocationVenueCorrection.VenueIdOriginal.Should().Be(apprenticeshipLocation.VenueId);
            apprenticeshipLocationVenueCorrection.CorruptionType.Should().Be(CorruptionType.VenueNotInProvidersLiveVenueList);
            apprenticeshipLocationVenueCorrection.UnfixableLocationVenueReason.Should().Be(UnfixableLocationVenueReasons.DuplicateMatchingVenues);
            apprenticeshipLocationVenueCorrection.DuplicateVenues.Should().BeEquivalentTo(potentialMatch, duplicateMatch);
        }
예제 #2
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);
        }