public void GetQueryStringParametersWhenMarkersTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "key",
                Center    = new Location(new Coordinate(1, 1)),
                ZoomLevel = 1,
                Markers   = new[]
                {
                    new MapMarker
                    {
                        Label     = "label",
                        Size      = MarkerSize.Normal,
                        Color     = "color",
                        Icon      = new MapMarkerIcon("url"),
                        Locations = new[]
                        {
                            new Location(new Coordinate(1, 1))
                        }
                    }
                }
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var markers         = queryStringParameters.FirstOrDefault(x => x.Key == "markers");
            var markersExpected = string.Join("|", request.Markers.Select(x => x.ToString()));

            Assert.IsNotNull(markers);
            Assert.AreEqual(markersExpected, markers.Value);
        }
Esempio n. 2
0
        public void GetQueryStringParametersTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "abc",
                Center    = new Location(1, 1),
                ZoomLevel = 2,
                Size      = new MapSize(100, 100),
                Type      = MapType.Hybrid,
                Scale     = MapScale.Large,
                Format    = ImageFormat.Png32,
                Language  = Language.Arabic,
                Region    = "abc"
            };

            var parameters = request.GetQueryStringParameters();

            Assert.IsNotNull(parameters);
            Assert.IsTrue(parameters.Any(x => x.Key == "center" && x.Value == "1,1"));
            Assert.IsTrue(parameters.Any(x => x.Key == "zoom" && x.Value == "2"));
            Assert.IsTrue(parameters.Any(x => x.Key == "size" && x.Value == "100x100"));
            Assert.IsTrue(parameters.Any(x => x.Key == "maptype" && x.Value == "hybrid"));
            Assert.IsTrue(parameters.Any(x => x.Key == "scale" && x.Value == "2"));
            Assert.IsTrue(parameters.Any(x => x.Key == "format" && x.Value == "png32"));
            Assert.IsTrue(parameters.Any(x => x.Key == "language" && x.Value == "ar"));
            Assert.IsTrue(parameters.Any(x => x.Key == "region" && x.Value == "abc"));
        }
        public void GetQueryStringParametersWhenStylesMultipleTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "key",
                Center    = new Location(new Coordinate(1, 1)),
                ZoomLevel = 1,
                Styles    = new List <MapStyle>
                {
                    new MapStyle
                    {
                        Feature = StyleFeature.Administrative_Country,
                        Element = StyleElement.Geometry_Fill,
                        Style   = new StyleRule
                        {
                            Hue             = "hue1",
                            Lightness       = 10,
                            Saturation      = 10,
                            Gamma           = 1,
                            InvertLightness = true,
                            Visibility      = StyleVisibility.Simplified,
                            Color           = "color1",
                            Weight          = 1
                        }
                    },
                    new MapStyle
                    {
                        Feature = StyleFeature.Administrative_Country,
                        Element = StyleElement.Geometry_Fill,
                        Style   = new StyleRule
                        {
                            Hue             = "hue2",
                            Lightness       = 11,
                            Saturation      = 11,
                            Gamma           = 2,
                            InvertLightness = false,
                            Visibility      = StyleVisibility.On,
                            Color           = "color2",
                            Weight          = 2
                        }
                    }
                }
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var style1         = queryStringParameters.FirstOrDefault(x => x.Key == "style");
            var styleExpected1 = request.Styles.First().ToString();

            Assert.IsNotNull(style1);
            Assert.AreEqual(styleExpected1, style1.Value);

            var style2         = queryStringParameters.LastOrDefault(x => x.Key == "style");
            var styleExpected2 = request.Styles.Last().ToString();

            Assert.IsNotNull(style2);
            Assert.AreEqual(styleExpected2, style2.Value);
        }
        public void GetQueryStringParametersWhenPathsTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "key",
                Center    = new Location(new Coordinate(1, 1)),
                ZoomLevel = 1,
                Paths     = new List <MapPath>
                {
                    new MapPath
                    {
                        Weight    = 10,
                        Geodesic  = false,
                        Color     = "color",
                        FillColor = "fillcolor",
                        Points    = new List <Location>
                        {
                            new Location(new Coordinate(1, 1)),
                            new Location(new Coordinate(2, 2))
                        }
                    }
                }
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var path         = queryStringParameters.FirstOrDefault(x => x.Key == "path");
            var pathExpected = request.Paths.First().ToString();

            Assert.IsNotNull(path);
            Assert.AreEqual(pathExpected, path.Value);
        }
        public void GetQueryStringParametersTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "key",
                Center    = new Location(new Coordinate(1, 1)),
                ZoomLevel = 1
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

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

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

            var size         = queryStringParameters.FirstOrDefault(x => x.Key == "size");
            var sizeExpected = request.Size.ToString();

            Assert.IsNotNull(size);
            Assert.AreEqual(sizeExpected, size.Value);

            var type         = queryStringParameters.FirstOrDefault(x => x.Key == "maptype");
            var typeExpected = request.Type.ToString().ToLower();

            Assert.IsNotNull(type);
            Assert.AreEqual(typeExpected, type.Value);

            var scale         = queryStringParameters.FirstOrDefault(x => x.Key == "scale");
            var scaleExpected = ((int)request.Scale).ToString();

            Assert.IsNotNull(scale);
            Assert.AreEqual(scaleExpected, scale.Value);

            var format         = queryStringParameters.FirstOrDefault(x => x.Key == "format");
            var formatExpected = request.Format.GetParameterName();

            Assert.IsNotNull(format);
            Assert.AreEqual(formatExpected, format.Value);

            var center         = queryStringParameters.FirstOrDefault(x => x.Key == "center");
            var centerExpected = request.Center.ToString();

            Assert.IsNotNull(center);
            Assert.AreEqual(centerExpected, center.Value);

            var zoom         = queryStringParameters.FirstOrDefault(x => x.Key == "zoom");
            var zoomExpected = request.ZoomLevel.ToString();

            Assert.IsNotNull(zoom);
            Assert.AreEqual(zoomExpected, zoom.Value);
        }
        public void GetQueryStringParametersWhenKeyIsEmptyTest()
        {
            var request = new StaticMapsRequest
            {
                Key = string.Empty
            };

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

            Assert.AreEqual("'Key' is required", exception.Message);
        }
        public void GetQueryStringParametersWhenZoomLevelIsNullTest()
        {
            var request = new StaticMapsRequest
            {
                Key    = "key",
                Center = new Location(new Coordinate(1, 1))
            };

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

            Assert.AreEqual("ZoomLevel is required, unless Markers, Paths or Visibles is defined", exception.Message);
        }
        public void GetQueryStringParametersWhenMarkersMultipleTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "key",
                Center    = new Location(new Coordinate(1, 1)),
                ZoomLevel = 1,
                Markers   = new[]
                {
                    new MapMarker
                    {
                        Label     = "label1",
                        Size      = MarkerSize.Normal,
                        Color     = "color2",
                        Icon      = new MapMarkerIcon("url1"),
                        Locations = new[]
                        {
                            new Location(new Coordinate(1, 1))
                        }
                    },
                    new MapMarker
                    {
                        Label     = "label2",
                        Size      = MarkerSize.Mid,
                        Color     = "color2",
                        Icon      = new MapMarkerIcon("url2"),
                        Locations = new[]
                        {
                            new Location(new Coordinate(2, 2))
                        }
                    }
                }
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var markers1         = queryStringParameters.FirstOrDefault(x => x.Key == "markers");
            var markersExpected1 = request.Markers.First().ToString();

            Assert.IsNotNull(markers1);
            Assert.AreEqual(markersExpected1, markers1.Value);

            var markers2         = queryStringParameters.LastOrDefault(x => x.Key == "markers");
            var markersExpected2 = request.Markers.Last().ToString();

            Assert.IsNotNull(markers2);
            Assert.AreEqual(markersExpected2, markers2.Value);
        }
Esempio n. 9
0
        public void GetQueryStringParametersWhenLocationOrPanoramaIdIsNullTest()
        {
            var request = new StaticMapsRequest
            {
                Key = "abc"
            };

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

            Assert.IsNotNull(exception);
            Assert.AreEqual(exception.Message, "Center is required, unless Markers, Path or Visibles is defined");
        }
Esempio n. 10
0
        public void GetQueryStringParametersWhenKeyIsStringEmptyTest()
        {
            var request = new StaticMapsRequest
            {
                Key = string.Empty
            };

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

            Assert.IsNotNull(exception);
            Assert.AreEqual(exception.Message, "Key is required");
        }
        public void GetQueryStringParametersWhenChannelTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "key",
                Center    = new Location(new Coordinate(1, 1)),
                ZoomLevel = 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);
        }
        public void GetQueryStringParametersWhenMarkersAndLocationsIsEmptyTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "key",
                Center    = new Location(new Coordinate(1, 1)),
                ZoomLevel = 1,
                Markers   = new[]
                {
                    new MapMarker
                    {
                        Label = "label"
                    }
                }
            };

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

            Assert.AreEqual("Markers must contain at least one location", exception.Message);
        }
        public void GetQueryStringParametersWhenPathsWhenPointsIsEmptyTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "key",
                Center    = new Location(new Coordinate(1, 1)),
                ZoomLevel = 1,
                Paths     = new List <MapPath>
                {
                    new MapPath
                    {
                        Color = "color"
                    }
                }
            };

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

            Assert.AreEqual("Paths must contain two or more locations", exception.Message);
        }
        public void GetQueryStringParametersWhenRegionTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "key",
                Center    = new Location(new Coordinate(1, 1)),
                ZoomLevel = 1,
                Region    = "region"
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var region         = queryStringParameters.FirstOrDefault(x => x.Key == "region");
            var regionExpected = request.Region;

            Assert.IsNotNull(region);
            Assert.AreEqual(regionExpected, region.Value);
        }
        public void GetQueryStringParametersWhenVisiblesTest()
        {
            var request = new StaticMapsRequest
            {
                Key       = "key",
                Center    = new Location(new Coordinate(1, 1)),
                ZoomLevel = 1,
                Visibles  = new[]
                {
                    new Location(new Coordinate(1, 1))
                }
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var visible         = queryStringParameters.FirstOrDefault(x => x.Key == "visible");
            var visibleExpected = string.Join("|", request.Visibles.Select(x => x.ToString()));

            Assert.IsNotNull(visible);
            Assert.AreEqual(visibleExpected, visible.Value);
        }