public void LookCloseToAreaButOutsideRadius_Should_NotRetrieveItems(double lat, double lng, int radius) { // Arrange var model = OrganizationFactory.GetListOfValidOrganizations(5); model.First().Address.Latitude = -8.05428; model.First().Address.Longitude = -34.8813; model.First().Address.Street = "Recife"; model.Last().Address.Latitude = 48.864716; model.Last().Address.Longitude = 2.349014; model.Last().Address.Street = "Paris"; model.First(t => t.Name == "Something 1").Address.Latitude = 51.426591; model.First(t => t.Name == "Something 1").Address.Longitude = 5.471808; model.First(t => t.Name == "Something 1").Address.Street = "Somewhere in Eindhoven 1"; model.First(t => t.Name == "Something 2").Address.Latitude = 51.423053; model.First(t => t.Name == "Something 2").Address.Longitude = 5.469985; model.First(t => t.Name == "Something 2").Address.Street = "Somewhere in Eindhoven 2"; model.First(t => t.Name == "Something 3").Address.Latitude = 51.424060; model.First(t => t.Name == "Something 3").Address.Longitude = 5.479824; model.First(t => t.Name == "Something 3").Address.Street = "Somewhere in Eindhoven 3"; // Act var mockQuery = new ListAllOrganizationsFromAreaTest(lat, lng, radius); var result = model.Where(mockQuery.Filter.Compile()).ToList(); // Assert Assert.False(result.Any()); }
public void SearchAllOrganizationsFromArea_Should_RetrieveOnlyWithinArea(int radius) { // Arrange var model = OrganizationFactory.GetListOfValidOrganizations(5); model.First().Address.Latitude = -8.05428; model.First().Address.Longitude = -34.8813; model.First().Address.Street = "Recife"; model.Last().Address.Latitude = 48.864716; model.Last().Address.Longitude = 2.349014; model.Last().Address.Street = "Paris"; model.First(t => t.Name == "Something 1").Address.Latitude = 51.426591; model.First(t => t.Name == "Something 1").Address.Longitude = 5.471808; model.First(t => t.Name == "Something 1").Address.Street = "Somewhere in Eindhoven 1"; model.First(t => t.Name == "Something 2").Address.Latitude = 51.423053; model.First(t => t.Name == "Something 2").Address.Longitude = 5.469985; model.First(t => t.Name == "Something 2").Address.Street = "Somewhere in Eindhoven 2"; model.First(t => t.Name == "Something 3").Address.Latitude = 51.424060; model.First(t => t.Name == "Something 3").Address.Longitude = 5.479824; model.First(t => t.Name == "Something 3").Address.Street = "Somewhere in Eindhoven 3"; // Act var mockQuery = new ListAllOrganizationsFromAreaTest(51.426760, 5.478174, radius); var result = model.Where(mockQuery.Filter.Compile()).ToList(); // Assert if (radius > 350) { Assert.True(result.Any(t => t.Address.Street == "Paris")); } else { Assert.False(result.Any(t => t.Address.Street == "Paris")); } Assert.False(result.Any(t => t.Address.Street == "Recife")); Assert.True(result.Count(t => t.Address.Street.Contains("Somewhere in Eindhoven")) == 3); }