Exemple #1
0
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertLocality2FromJson_WithNullCountry()
        {
            var json = new JsonPlace
            {
                Locality2Name = "locality2 name",
                Locality2     = null,
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Locality2.ShouldNotBeNull();
            model.Locality2.Name.ShouldEqual("locality2 name");
            model.Locality2.Type.ShouldBeNull();
        }
Exemple #2
0
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertTypeFromJson_WithNullType()
        {
            var json = new JsonPlace
            {
                TypeName = "type name",
                Type     = null,
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Type.ShouldNotBeNull();
            model.Type.Name.ShouldEqual("type name");
            model.Type.Code.ShouldEqual(default(int));
        }
Exemple #3
0
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertAdmin3FromJson_WithNullCountry()
        {
            var json = new JsonPlace
            {
                Admin3Name = "admin3 name",
                Admin3     = null,
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Admin3.ShouldNotBeNull();
            model.Admin3.Name.ShouldEqual("admin3 name");
            model.Admin3.Code.ShouldBeNull();
            model.Admin3.Type.ShouldBeNull();
        }
Exemple #4
0
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertCountryFromJson_WithNullCountry()
        {
            var json = new JsonPlace
            {
                CountryName = "country name",
                Country     = null,
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Country.ShouldNotBeNull();
            model.Country.Name.ShouldEqual("country name");
            model.Country.Code.ShouldBeNull();
            model.Country.Type.ShouldBeNull();
        }
Exemple #5
0
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertTypeFromJson_WithNonNullTypeValues()
        {
            var json = new JsonPlace
            {
                TypeName = "type name",
                Type     = new JsonPlaceTypeAttributes {
                    Code = 11,
                },
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Type.ShouldNotBeNull();
            model.Type.Name.ShouldEqual("type name");
            model.Type.Code.ShouldEqual(11);
        }
Exemple #6
0
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertAutosFromJson()
        {
            var json = new JsonPlace
            {
                WoeId    = 72,
                Name     = "name",
                Language = "language",
                Uri      = new Uri("http://ngeo.codeplex.com"),
                Center   = new Point {
                    Latitude = 9.84, Longitude = 52.445,
                },
                BoundingBox = new BoundingBox
                {
                    Northeast = new Point {
                        Latitude = 8.541, Longitude = 77.93,
                    },
                    Southwest = new Point {
                        Latitude = 4.362, Longitude = 129.63,
                    },
                },
                AreaRank       = 43,
                PopulationRank = 33,
                Postal         = "postal",
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.WoeId.ShouldEqual(json.WoeId);
            model.Name.ShouldEqual(json.Name);
            model.Language.ShouldEqual(json.Language);
            model.Center.ShouldNotBeNull();
            model.Center.ShouldEqual(json.Center);
            model.Center.Latitude.ShouldEqual(json.Center.Latitude);
            model.Center.Longitude.ShouldEqual(json.Center.Longitude);
            model.BoundingBox.ShouldNotBeNull();
            model.BoundingBox.Northeast.ShouldNotBeNull();
            model.BoundingBox.Northeast.Latitude.ShouldEqual(json.BoundingBox.Northeast.Latitude);
            model.BoundingBox.Northeast.Longitude.ShouldEqual(json.BoundingBox.Northeast.Longitude);
            model.BoundingBox.Southwest.ShouldNotBeNull();
            model.BoundingBox.Southwest.Latitude.ShouldEqual(json.BoundingBox.Southwest.Latitude);
            model.BoundingBox.Southwest.Longitude.ShouldEqual(json.BoundingBox.Southwest.Longitude);
            model.AreaRank.ShouldEqual(json.AreaRank);
            model.PopulationRank.ShouldEqual(json.PopulationRank);
            model.Postal.ShouldEqual(json.Postal);
        }
Exemple #7
0
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertLocality2FromJson_WithNonNullValues()
        {
            var json = new JsonPlace
            {
                Locality2Name = "locality2 name",
                Locality2     = new JsonLocalityAttributes
                {
                    Type = "locality2 type"
                },
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Locality2.ShouldNotBeNull();
            model.Locality2.Name.ShouldEqual("locality2 name");
            model.Locality2.Type.ShouldEqual("locality2 type");
        }
Exemple #8
0
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertAdmin3FromJson_WithNonNullValues()
        {
            var json = new JsonPlace
            {
                Admin3Name = "admin3 name",
                Admin3     = new JsonAdminAttributes
                {
                    Code = "admin3 code",
                    Type = "admin3 type"
                },
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Admin3.ShouldNotBeNull();
            model.Admin3.Name.ShouldEqual("admin3 name");
            model.Admin3.Code.ShouldEqual("admin3 code");
            model.Admin3.Type.ShouldEqual("admin3 type");
        }
Exemple #9
0
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertCountryFromJson_WithNonNullValues()
        {
            var json = new JsonPlace
            {
                CountryName = "country name",
                Country     = new JsonAdminAttributes
                {
                    Code = "country code",
                    Type = "country type"
                },
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Country.ShouldNotBeNull();
            model.Country.Name.ShouldEqual("country name");
            model.Country.Code.ShouldEqual("country code");
            model.Country.Type.ShouldEqual("country type");
        }
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertLocality2FromJson_WithNullCountry()
        {
            var json = new JsonPlace
            {
                Locality2Name = "locality2 name",
                Locality2 = null,
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Locality2.ShouldNotBeNull();
            model.Locality2.Name.ShouldEqual("locality2 name");
            model.Locality2.Type.ShouldBeNull();
        }
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertCountryFromJson_WithNullCountry()
        {
            var json = new JsonPlace
            {
                CountryName = "country name",
                Country = null,
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Country.ShouldNotBeNull();
            model.Country.Name.ShouldEqual("country name");
            model.Country.Code.ShouldBeNull();
            model.Country.Type.ShouldBeNull();
        }
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertLocality2FromJson_WithNonNullValues()
        {
            var json = new JsonPlace
            {
                Locality2Name = "locality2 name",
                Locality2 = new JsonLocalityAttributes
                {
                    Type = "locality2 type"
                },
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Locality2.ShouldNotBeNull();
            model.Locality2.Name.ShouldEqual("locality2 name");
            model.Locality2.Type.ShouldEqual("locality2 type");
        }
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertCountryFromJson_WithNonNullValues()
        {
            var json = new JsonPlace
            {
                CountryName = "country name",
                Country = new JsonAdminAttributes
                {
                    Code = "country code",
                    Type = "country type"
                },
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Country.ShouldNotBeNull();
            model.Country.Name.ShouldEqual("country name");
            model.Country.Code.ShouldEqual("country code");
            model.Country.Type.ShouldEqual("country type");
        }
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertAutosFromJson()
        {
            var json = new JsonPlace
            {
                WoeId = 72,
                Name = "name",
                Language = "language",
                Uri = new Uri("http://ngeo.codeplex.com"),
                Center = new Point { Latitude = 9.84, Longitude = 52.445, },
                BoundingBox = new BoundingBox
                {
                    Northeast = new Point { Latitude = 8.541, Longitude = 77.93, },
                    Southwest = new Point { Latitude = 4.362, Longitude = 129.63, },
                },
                AreaRank = 43,
                PopulationRank = 33,
                Postal = "postal",
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.WoeId.ShouldEqual(json.WoeId);
            model.Name.ShouldEqual(json.Name);
            model.Language.ShouldEqual(json.Language);
            model.Center.ShouldNotBeNull();
            model.Center.ShouldEqual(json.Center);
            model.Center.Latitude.ShouldEqual(json.Center.Latitude);
            model.Center.Longitude.ShouldEqual(json.Center.Longitude);
            model.BoundingBox.ShouldNotBeNull();
            model.BoundingBox.Northeast.ShouldNotBeNull();
            model.BoundingBox.Northeast.Latitude.ShouldEqual(json.BoundingBox.Northeast.Latitude);
            model.BoundingBox.Northeast.Longitude.ShouldEqual(json.BoundingBox.Northeast.Longitude);
            model.BoundingBox.Southwest.ShouldNotBeNull();
            model.BoundingBox.Southwest.Latitude.ShouldEqual(json.BoundingBox.Southwest.Latitude);
            model.BoundingBox.Southwest.Longitude.ShouldEqual(json.BoundingBox.Southwest.Longitude);
            model.AreaRank.ShouldEqual(json.AreaRank);
            model.PopulationRank.ShouldEqual(json.PopulationRank);
            model.Postal.ShouldEqual(json.Postal);
        }
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertAdmin3FromJson_WithNullCountry()
        {
            var json = new JsonPlace
            {
                Admin3Name = "admin3 name",
                Admin3 = null,
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Admin3.ShouldNotBeNull();
            model.Admin3.Name.ShouldEqual("admin3 name");
            model.Admin3.Code.ShouldBeNull();
            model.Admin3.Type.ShouldBeNull();
        }
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertTypeFromJson_WithNonNullTypeValues()
        {
            var json = new JsonPlace
            {
                TypeName = "type name",
                Type = new JsonPlaceTypeAttributes { Code = 11, },
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Type.ShouldNotBeNull();
            model.Type.Name.ShouldEqual("type name");
            model.Type.Code.ShouldEqual(11);
        }
 public void Yahoo_GeoPlanet_JsonPlace_ShouldBePublic()
 {
     var model = new JsonPlace();
     model.ShouldNotBeNull();
 }
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertTypeFromJson_WithNullType()
        {
            var json = new JsonPlace
            {
                TypeName = "type name",
                Type = null,
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Type.ShouldNotBeNull();
            model.Type.Name.ShouldEqual("type name");
            model.Type.Code.ShouldEqual(default(int));
        }
Exemple #19
0
        public void Yahoo_GeoPlanet_JsonPlace_ShouldBePublic()
        {
            var model = new JsonPlace();

            model.ShouldNotBeNull();
        }
Exemple #20
0
        internal static Place ToPlace(this JsonPlace jsonPlace)
        {
            if (jsonPlace == null)
            {
                throw new ArgumentNullException("jsonPlace");
            }

            var place = new Place
            {
                WoeId          = jsonPlace.WoeId,
                Name           = jsonPlace.Name,
                Language       = jsonPlace.Language,
                Uri            = jsonPlace.Uri,
                Center         = jsonPlace.Center,
                BoundingBox    = jsonPlace.BoundingBox,
                AreaRank       = jsonPlace.AreaRank,
                PopulationRank = jsonPlace.PopulationRank,
                Postal         = jsonPlace.Postal,
                Type           = (jsonPlace.Type != null || !string.IsNullOrWhiteSpace(jsonPlace.TypeName)) ? new PlaceType
                {
                    Name = jsonPlace.TypeName,
                    Code = (jsonPlace.Type != null) ? jsonPlace.Type.Code : default(int),
                } : null,
                Country = (jsonPlace.Country != null || !string.IsNullOrWhiteSpace(jsonPlace.CountryName)) ? new Admin
                {
                    Name = jsonPlace.CountryName,
                    Code = (jsonPlace.Country != null) ? jsonPlace.Country.Code : null,
                    Type = (jsonPlace.Country != null) ? jsonPlace.Country.Type : null,
                } : null,
                Admin1 = (jsonPlace.Admin1 != null || !string.IsNullOrWhiteSpace(jsonPlace.Admin1Name)) ? new Admin
                {
                    Name = jsonPlace.Admin1Name,
                    Code = (jsonPlace.Admin1 != null) ? jsonPlace.Admin1.Code : null,
                    Type = (jsonPlace.Admin1 != null) ? jsonPlace.Admin1.Type : null,
                } : null,
                Admin2 = (jsonPlace.Admin2 != null || !string.IsNullOrWhiteSpace(jsonPlace.Admin2Name)) ? new Admin
                {
                    Name = jsonPlace.Admin2Name,
                    Code = (jsonPlace.Admin2 != null) ? jsonPlace.Admin2.Code : null,
                    Type = (jsonPlace.Admin2 != null) ? jsonPlace.Admin2.Type : null,
                } : null,
                Admin3 = (jsonPlace.Admin3 != null || !string.IsNullOrWhiteSpace(jsonPlace.Admin3Name)) ? new Admin
                {
                    Name = jsonPlace.Admin3Name,
                    Code = (jsonPlace.Admin3 != null) ? jsonPlace.Admin3.Code : null,
                    Type = (jsonPlace.Admin3 != null) ? jsonPlace.Admin3.Type : null,
                } : null,
                Locality1 = (jsonPlace.Locality1 != null || !string.IsNullOrWhiteSpace(jsonPlace.Locality1Name)) ? new Locality
                {
                    Name = jsonPlace.Locality1Name,
                    Type = (jsonPlace.Locality1 != null) ? jsonPlace.Locality1.Type : null,
                } : null,
                Locality2 = (jsonPlace.Locality2 != null || !string.IsNullOrWhiteSpace(jsonPlace.Locality2Name)) ? new Locality
                {
                    Name = jsonPlace.Locality2Name,
                    Type = (jsonPlace.Locality2 != null) ? jsonPlace.Locality2.Type : null,
                } : null,
            };

            return(place);
        }
        public void Yahoo_GeoPlanet_JsonConverter_ToPlace_ShouldConvertAdmin3FromJson_WithNonNullValues()
        {
            var json = new JsonPlace
            {
                Admin3Name = "admin3 name",
                Admin3 = new JsonAdminAttributes
                {
                    Code = "admin3 code",
                    Type = "admin3 type"
                },
            };

            var model = json.ToPlace();

            model.ShouldNotBeNull();
            model.Admin3.ShouldNotBeNull();
            model.Admin3.Name.ShouldEqual("admin3 name");
            model.Admin3.Code.ShouldEqual("admin3 code");
            model.Admin3.Type.ShouldEqual("admin3 type");
        }