public new void Setup() { base.Setup(); var orchestratorResult = new ClosestLocationsViewModel { ApprenticeshipId = APPRENTICESHIP_ID, Ukprn = UKPRN, ProviderName = "Test Provider", LocationId = 4444, Locations = new List <CloseLocationViewModel> { new CloseLocationViewModel { LocationId = 12, Distance = 1.22d, AddressWithoutPostCode = "No 1, The Street, Somewhere", PostCode = "AB12 3FG" }, new CloseLocationViewModel { LocationId = 23, Distance = 3.44d, AddressWithoutPostCode = "", PostCode = "SW12 4ED" } } }; _mockTrainingProviderOrchestrator = new Mock <ITrainingProviderOrchestrator>(); _mockTrainingProviderOrchestrator.Setup(x => x.GetClosestLocations(APPRENTICESHIP_ID, UKPRN, LOCATION_ID, POSTCODE)).ReturnsAsync(orchestratorResult); _sut = new ClosestLocationsViewComponent(_mockTrainingProviderOrchestrator.Object) { ViewComponentContext = _viewComponentContext }; }
public ClosestLocationsViewModel Map(string apprenticeshipId, int ukprn, int locationId, string postcode, GetClosestLocationsResponse source) { var model = new ClosestLocationsViewModel { ApprenticeshipId = apprenticeshipId, ProviderName = source.ProviderName, Ukprn = ukprn, LocationId = locationId, PostCode = postcode, Locations = source.Results.Hits.Select(x => new CloseLocationViewModel { LocationId = x.LocationId, Distance = x.Distance, PostCode = x.Address.Postcode, AddressWithoutPostCode = x.Address.GetCommaDelimitedAddress() }).ToList() }; return(model); }