Beispiel #1
0
        public void ConvertToCitySearchResult_ThrowsExceptionWhenBadFormat()
        {
            IKinoheldJsonWorker worker = new KinoheldJsonWorker();

            Assert.Throws <InvalidCastException>(() => worker.ConvertToCitySearchResult(JObject.Parse(
                                                                                            "{\r\n  \"citiess\": [],\r\n  \"postcodes\": []}")));
            Assert.Throws <InvalidCastException>(() => worker.ConvertToCitySearchResult(JObject.Parse(
                                                                                            "{\r\n  \"cities\": [],\r\n  \"postcodess\": []}")));
        }
Beispiel #2
0
        public void ConvertToCitySearchResult_ConvertsResultSucessfully2()
        {
            IKinoheldJsonWorker worker = new KinoheldJsonWorker();
            var cities = worker.ConvertToCitySearchResult(
                JObject.Parse("{\r\n  \"cities\": [\r\n    {\r\n      \"name\": \"Aurich\",\r\n      \"detailUrl\": {\r\n        \"relativeUrl\": \"/kino-aurich/\"\r\n      }\r\n    },\r\n    {\r\n      \"name\": \"Aurach, Mittelfranken\",\r\n      \"detailUrl\": {\r\n        \"relativeUrl\": \"/kino-aurach-mittelfranken/\"\r\n      }\r\n    },\r\n    {\r\n      \"name\": \"Aurachtal\",\r\n      \"detailUrl\": {\r\n        \"relativeUrl\": \"/kino-aurachtal/\"\r\n      }\r\n    },\r\n    {\r\n      \"name\": \"Aura im Sinngrund\",\r\n      \"detailUrl\": {\r\n        \"relativeUrl\": \"/kino-aura-im-sinngrund/\"\r\n      }\r\n    },\r\n    {\r\n      \"name\": \"Aura an der Saale\",\r\n      \"detailUrl\": {\r\n        \"relativeUrl\": \"/kino-aura-an-der-saale/\"\r\n      }\r\n    },\r\n    {\r\n      \"name\": \"Auringen\",\r\n      \"detailUrl\": {\r\n        \"relativeUrl\": \"/kino-auringen/\"\r\n      }\r\n    }\r\n  ],\r\n  \"postcodes\": []\r\n}"));

            Assert.NotNull(cities);
            Assert.AreEqual(6, cities.Cities.Count);
            Assert.AreEqual(0, cities.PostalCodes.Count);
            Assert.AreEqual("Aurich", cities.Cities[0].Name);
            Assert.AreEqual("Auringen", cities.Cities[5].Name);
        }
Beispiel #3
0
        public void ConvertToCitySearchResult_ConvertsResultSucessfully()
        {
            IKinoheldJsonWorker worker = new KinoheldJsonWorker();
            var cities = worker.ConvertToCitySearchResult(
                JObject.Parse(
                    "{\r\n  \"cities\": [],\r\n  \"postcodes\": [\r\n    {\r\n      \"postcode\": \"26603\",\r\n      \"city\": {\r\n        \"name\": \"Aurich\",\r\n        \"detailUrl\": {\r\n          \"url\": \"/kino-aurich/\"\r\n        }\r\n      }\r\n    },\r\n    {\r\n      \"postcode\": \"26605\",\r\n      \"city\": {\r\n        \"name\": \"Aurich\",\r\n        \"detailUrl\": {\r\n          \"relativeUrl\": \"/kino-aurich/\"\r\n        }\r\n      }\r\n    },\r\n    {\r\n      \"postcode\": \"26607\",\r\n      \"city\": {\r\n        \"name\": \"Aurich\",\r\n        \"detailUrl\": {\r\n          \"relativeUrl\": \"/kino-aurich/\"\r\n        }\r\n      }\r\n    },\r\n    {\r\n      \"postcode\": \"26655\",\r\n      \"city\": {\r\n        \"name\": \"Westerstede\",\r\n        \"detailUrl\": {\r\n          \"relativeUrl\": \"/kino-westerstede/\"\r\n        }\r\n      }\r\n    },\r\n    {\r\n      \"postcode\": \"26624\",\r\n      \"city\": {\r\n        \"name\": \"Südbrookmerland\",\r\n        \"detailUrl\": {\r\n    \"relativeUrl\": \"/kino-suedbrookmerland/\"\r\n        }\r\n      }\r\n    },\r\n    {\r\n      \"postcode\": \"26629\",\r\n      \"city\": {\r\n        \"name\": \"Großefehn\",\r\n        \"detailUrl\": {\r\n          \"relativeUrl\": \"/kino-grossefehn/\"\r\n        }\r\n      }\r\n    },\r\n    {\r\n      \"postcode\": \"26639\",\r\n      \"city\": {\r\n        \"name\": \"Wiesmoor\",\r\n        \"detailUrl\": {\r\n          \"relativeUrl\": \"/kino-wiesmoor/\"\r\n        }\r\n      }\r\n    },\r\n    {\r\n      \"postcode\": \"26683\",\r\n      \"city\": {\r\n        \"name\": \"Saterland\",\r\n        \"detailUrl\": {\r\n          \"relativeUrl\": \"/kino-saterland/\"\r\n        }\r\n      }\r\n    },\r\n    {\r\n      \"postcode\": \"26676\",\r\n      \"city\": {\r\n        \"name\": \"Barßel\",\r\n        \"detailUrl\": {\r\n          \"relativeUrl\": \"/kino-barssel/\"\r\n        }\r\n      }\r\n    },\r\n    {\r\n      \"postcode\": \"26632\",\r\n      \"city\": {\r\n        \"name\": \"Ihlow, Ostfriesland\",\r\n        \"detailUrl\": {\r\n          \"relativeUrl\": \"/kino-ihlow-ostfriesland/\"\r\n        }\r\n      }\r\n    }\r\n  ]\r\n}"));

            Assert.NotNull(cities);
            Assert.AreEqual(0, cities.Cities.Count);
            Assert.AreEqual(10, cities.PostalCodes.Count);
            Assert.AreEqual(26603, cities.PostalCodes[0].Code);
            Assert.AreEqual("Aurich", cities.PostalCodes[0].City.Name);
            Assert.AreEqual(26632, cities.PostalCodes[9].Code);
            Assert.AreEqual("Ihlow, Ostfriesland", cities.PostalCodes[9].City.Name);
        }
Beispiel #4
0
        public void ConvertToCityResult_DoesNotAllowNullJson()
        {
            IKinoheldJsonWorker worker = new KinoheldJsonWorker();

            Assert.Throws <ArgumentNullException>(() => worker.ConvertToCitySearchResult(null));
        }