public HotSpotModel NearestHotSpot(HotSpotModel hotspot) { var nearest = _hotSpotList.OrderBy(x => DistanceBetweenHotSpots(hotspot, x)) .First(x => x.Number != hotspot.Number); return(nearest); }
public bool Update(int id, HotSpotModel hotSpotById) { var currentHotSpot = GetById(id); currentHotSpot.LocationName = hotSpotById.LocationName; currentHotSpot.LatitudeX = hotSpotById.LatitudeX; currentHotSpot.LongitudeY = hotSpotById.LongitudeY; return(true); }
private double DistanceBetweenHotSpots(HotSpotModel x, HotSpotModel y) { var xLatitude = double.Parse(x.LatitudeX, CultureInfo.InvariantCulture); var xLongitude = double.Parse(x.LongitudeY, CultureInfo.InvariantCulture); var yLatitude = double.Parse(y.LatitudeX, CultureInfo.InvariantCulture); var yLongitude = double.Parse(y.LongitudeY, CultureInfo.InvariantCulture); var distance = GeoCalculator.GetDistance(xLatitude, xLongitude, yLatitude, yLongitude); return(distance); }
public void Should_Get_All_Favorites() { //Arrange var hotspot = new HotSpotService(); var testingHotSpot = new HotSpotModel() { LocationName = "Test123", }; hotspot.AddHotSpot(testingHotSpot); hotspot.MarkAsFavorite(testingHotSpot.Number); //Act var sut = hotspot.GetAllFavorites(); //Assert Assert.Collection(sut, item => Assert.True(item.FavoriteHotSpot)); }
public void Should_Add_Hotspot() { //Arrange HotSpotService hs = new HotSpotService(); HotSpotModel hotspot = new HotSpotModel() { LocationName = "Burzyńskiego 12", LatitudeX = "54", LongitudeY = "18", }; //Act var sut = hs.AddHotSpot(hotspot); var lastHotSpot = hs.GetAll().TakeLast(1); //Assert Assert.Collection(lastHotSpot, item => Assert.Contains("Burzyńskiego", item.LocationName)); Assert.Collection(lastHotSpot, item => Assert.Contains("54", item.LatitudeX)); Assert.Collection(lastHotSpot, item => Assert.Contains("18", item.LongitudeY)); }
public void Should_Update_Old_Data_In_Hotspot() { //Arrange var hotspotService = new HotSpotService(); var allHotSpots = hotspotService.GetAll(); var updatedHotSpot = new HotSpotModel() { LocationName = "testing", LatitudeX = "111", LongitudeY = "222", //Number pop and FakeId prop are not taking care into consideration for the update purpose //Therefore it's values will be the same as used to be Number = 1, fakeID = "LOK001" }; var currentHotSpot = hotspotService.GetById(1); //Act hotspotService.Update(1, updatedHotSpot); //Assert currentHotSpot.Should().BeEquivalentTo(updatedHotSpot); }
public IActionResult Nearest(HotSpotModel hotspot) { return(View("Nearest", _mapper.Map <HotSpotModel, HotSpotViewModel>(hotspot))); }
public HotSpotModel AddHotSpot(HotSpotModel hotspot) { hotspot.Number = _hotSpotList.Max(x => x.Number) + 1; _hotSpotList.Add(hotspot); return(hotspot); }