Example #1
0
        public void GetLocationsInRadius_ValidZipCodeValidRadiusNoExistingLocationsNearby_ReturnsEmptyList()
        {
            var locationService = new LocationService(new FakeLocationRepository());

            // There should be nothing within one mile of this ZIP code (see FakeLocationRepository's constructor).
            IEnumerable<LocationInRadius> locationsNearby = locationService.GetLocationsInRadius("99950", 1.0);

            // The Location itself is returned.
            Assert.AreEqual(1, locationsNearby.Count());
        }
Example #2
0
        public void GetLocationsInRadius_ValidZipCodeNegativeRadiusExistingLocationsNearby_ThrowsArgumentOutOfRangeException()
        {
            var locationService = new LocationService(new FakeLocationRepository());

            var ex = Assert.Throws<ArgumentOutOfRangeException>(() => locationService.GetLocationsInRadius("95814", -100.0));
            Assert.True(ex.Message.StartsWith("Radius must be greater than 0"));
        }
Example #3
0
        public void GetLocationsInRadius_ValidZipCodeValidRadiusExistingLocationsNearby_ReturnsNonEmptyList()
        {
            var locationService = new LocationService(new FakeLocationRepository());

            IEnumerable<LocationInRadius> locationsNearby = locationService.GetLocationsInRadius("95814", 5.0);

            Assert.AreNotEqual(0, locationsNearby.Count());
        }
Example #4
0
        public void GetLocationsInRadius_InvalidZipCodeInvalidRadiusExistingLocationsNearby_ThrowsArgumentOutOfRangeException()
        {
            var locationService = new LocationService(new FakeLocationRepository());

            var ex = Assert.Throws<ArgumentOutOfRangeException>(() => locationService.GetLocationsInRadius("abcdefkjkjkjkjk", -3.14159));
            Assert.True(ex.Message.StartsWith("Radius must be greater than 0"));
        }