Пример #1
0
        public void ConstructorTest()
        {
            var plusCode = new PlusCode("global", "local");

            Assert.AreEqual("global", plusCode.GlobalCode);
            Assert.AreEqual("local", plusCode.LocalCode);
        }
Пример #2
0
        public void ConstructorWhenPlusCodeTest()
        {
            var plusCode = new PlusCode("global", "local");
            var location = new LocationEx(plusCode);

            Assert.AreEqual(plusCode.ToString(), location.String);
        }
Пример #3
0
        public void ToStringTest()
        {
            var plusCode = new PlusCode("global", "local");

            var toString = plusCode.ToString();

            Assert.AreEqual($"{plusCode.GlobalCode}{plusCode.LocalCode}", toString);
        }
Пример #4
0
 public void ConstructorWhenLocalCodeIsNullTest()
 {
     Assert.DoesNotThrow(() =>
     {
         var plusCode = new PlusCode("global");
         Assert.IsNotNull(plusCode);
     });
 }
Пример #5
0
 public void ConstructorWhenGlobalCodeIsNullTest()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var plusCode = new PlusCode(null, "local");
         Assert.IsNotNull(plusCode);
     });
 }
Пример #6
0
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="node">Place node from response</param>
    public OnlineMapsGooglePlacesResult(OnlineMapsXML node)
    {
        List <Photo>  photos       = new List <Photo>();
        List <string> types        = new List <string>();
        List <string> weekday_text = new List <string>();

        foreach (OnlineMapsXML n in node)
        {
            if (n.name == "name")
            {
                name = n.Value();
            }
            else if (n.name == "id")
            {
                id = n.Value();
            }
            else if (n.name == "vicinity")
            {
                vicinity = n.Value();
            }
            else if (n.name == "type")
            {
                types.Add(n.Value());
            }
            else if (n.name == "geometry")
            {
                location = OnlineMapsXML.GetVector2FromNode(n[0]);
            }
            else if (n.name == "rating")
            {
                rating = n.Value <float>();
            }
            else if (n.name == "icon")
            {
                icon = n.Value();
            }
            else if (n.name == "reference")
            {
                reference = n.Value();
            }
            else if (n.name == "place_id")
            {
                place_id = n.Value();
            }
            else if (n.name == "scope")
            {
                scope = n.Value();
            }
            else if (n.name == "price_level")
            {
                price_level = n.Value <int>();
            }
            else if (n.name == "formatted_address")
            {
                formatted_address = n.Value();
            }
            else if (n.name == "opening_hours")
            {
                open_now = n.Get <string>("open_now") == "true";
                foreach (OnlineMapsXML wdt in n.FindAll("weekday_text"))
                {
                    weekday_text.Add(wdt.Value());
                }
            }
            else if (n.name == "photo")
            {
                photos.Add(new Photo(n));
            }
            else if (n.name == "plus_code")
            {
                plus_code = new PlusCode(n);
            }
            else
            {
                Debug.Log(n.name);
            }
        }

        this.photos       = photos.ToArray();
        this.types        = types.ToArray();
        this.weekday_text = weekday_text.ToArray();
    }
Пример #7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="plusCode">The <see cref="PlusCode"/>.</param>
 public LocationEx(PlusCode plusCode)
 {
     this.String = plusCode.ToString();
 }