public void GetQueryStringParametersWhenPathTest()
        {
            var request = new ElevationRequest
            {
                Key  = "key",
                Path = new[]
                {
                    new Coordinate(1, 1),
                    new Coordinate(2, 2)
                },
                Samples = 2
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var path         = queryStringParameters.FirstOrDefault(x => x.Key == "path");
            var pathExpected = string.Join("|", request.Path);

            Assert.IsNotNull(path);
            Assert.AreEqual(pathExpected, path.Value);

            var samples = queryStringParameters.FirstOrDefault(x => x.Key == "samples");

            Assert.AreEqual(request.Samples.ToString(), samples.Value);
        }
        public void GetQueryStringParametersWhenLocationsTest()
        {
            var request = new ElevationRequest
            {
                Key       = "key",
                Locations = new[]
                {
                    new Coordinate(1, 1)
                }
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var key         = queryStringParameters.SingleOrDefault(x => x.Key == "key");
            var keyExpected = request.Key;

            Assert.IsNotNull(key);
            Assert.AreEqual(keyExpected, key.Value);

            var locations         = queryStringParameters.FirstOrDefault(x => x.Key == "locations");
            var locationsExpected = string.Join("|", request.Locations);

            Assert.IsNotNull(locations);
            Assert.AreEqual(locationsExpected, locations.Value);
        }
        public void GetQueryStringParametersTest()
        {
            var request = new ElevationRequest
            {
                Path    = new[] { new Location(40.7141289, -73.9614074) },
                Samples = 2
            };

            Assert.DoesNotThrow(() => request.GetQueryStringParameters());
        }
        public void GetQueryStringParametersWhenKeyIsEmptyTest()
        {
            var request = new ElevationRequest
            {
                Key = string.Empty
            };

            var exception = Assert.Throws <ArgumentException>(() => request.GetQueryStringParameters());

            Assert.AreEqual("'Key' is required", exception.Message);
        }
        public void GetQueryStringParametersWhenPathIsEmptyTest()
        {
            var request = new ElevationRequest
            {
                Key  = "key",
                Path = new Coordinate[0]
            };

            var exception = Assert.Throws <ArgumentException>(() => request.GetQueryStringParameters());

            Assert.AreEqual("'Locations' or 'Path' is required", exception.Message);
        }
        public void GetQueryStringParametersWhenLocationsIsNullTest()
        {
            var request = new ElevationRequest
            {
                Key       = "key",
                Locations = null
            };

            var exception = Assert.Throws <ArgumentException>(() => request.GetQueryStringParameters());

            Assert.AreEqual("'Locations' or 'Path' is required", exception.Message);
        }
        public void GetQueryStringParametersWhenPathAndLocationIsNullTest()
        {
            var request = new ElevationRequest();

            var exception = Assert.Throws <ArgumentException>(() =>
            {
                var parameters = request.GetQueryStringParameters();
                Assert.IsNull(parameters);
            });

            Assert.IsNotNull(exception);
            Assert.AreEqual(exception.Message, "Locations or Path is required");
        }
        public void GetQueryStringParametersWhenPathContainsLessThanTwoCoordinatesTest()
        {
            var request = new ElevationRequest
            {
                Key  = "key",
                Path = new[]
                {
                    new Coordinate(1, 1)
                }
            };

            var exception = Assert.Throws <ArgumentException>(() => request.GetQueryStringParameters());

            Assert.AreEqual("A minimum of two coordinates is required when using 'Path'", exception.Message);
        }
        public void GetQueryStringParametersWhenPathAndLocationTest()
        {
            var request = new ElevationRequest
            {
                Path      = new[] { new Location(40.7141289, -73.9614074) },
                Locations = new[] { new Location(40.7141289, -73.9614074) }
            };

            var exception = Assert.Throws <ArgumentException>(() =>
            {
                var parameters = request.GetQueryStringParameters();
                Assert.IsNull(parameters);
            });

            Assert.IsNotNull(exception);
            Assert.AreEqual(exception.Message, "Path and Locations cannot both be specified");
        }
        public void GetQueryStringParametersWhenPathAndSamplesIsNullTest()
        {
            var request = new ElevationRequest
            {
                Path    = new[] { new Location(40.7141289, -73.9614074) },
                Samples = null
            };

            var exception = Assert.Throws <ArgumentException>(() =>
            {
                var parameters = request.GetQueryStringParameters();
                Assert.IsNull(parameters);
            });

            Assert.IsNotNull(exception);
            Assert.AreEqual(exception.Message, "Samples is required, when using Path");
        }
        public void GetQueryStringParametersWhenPathIsNotEmptyAndSamplesIsNullTest()
        {
            var request = new ElevationRequest
            {
                Key  = "key",
                Path = new[]
                {
                    new Coordinate(1, 1),
                    new Coordinate(2, 2)
                },
                Samples = null
            };

            var exception = Assert.Throws <ArgumentException>(() => request.GetQueryStringParameters());

            Assert.AreEqual("'Samples' is required, when using 'Path'", exception.Message);
        }
        public void GetQueryStringParametersWhenPathIsNotEmptyAndLocationsIsNotEmptyTest()
        {
            var request = new ElevationRequest
            {
                Key       = "key",
                Locations = new List <Coordinate>
                {
                    new Coordinate(0, 0)
                },
                Path = new List <Coordinate>
                {
                    new Coordinate(0, 0)
                }
            };

            var exception = Assert.Throws <ArgumentException>(() => request.GetQueryStringParameters());

            Assert.AreEqual("'Path' and 'Locations' cannot both be specified", exception.Message);
        }
        public void GetQueryStringParametersWhenChannelTest()
        {
            var request = new ElevationRequest
            {
                Key       = "key",
                Locations = new[]
                {
                    new Coordinate(1, 1)
                },
                Channel = "channel"
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var channel         = queryStringParameters.FirstOrDefault(x => x.Key == "channel");
            var channelExpected = request.Channel;

            Assert.IsNotNull(channel);
            Assert.AreEqual(channelExpected, channel.Value);
        }