Ejemplo n.º 1
0
        public void TestToursRequest()
        {
            string         endPoint = String.Format(endpointLocator, serviceUrl, verbTours);
            HttpWebRequest request  = CreateRequest(endPoint);

            WebResponse response       = request.GetResponse();
            Stream      responseStream = response.GetResponseStream();

            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ToursQueryResult));
            ToursQueryResult           tours      = (ToursQueryResult)serializer.ReadObject(responseStream);

            Assert.AreNotEqual <int>(0, tours.d.Count, "No tours returned");
        }
Ejemplo n.º 2
0
        public void TestToursBookmarkUrl()
        {
            string         endPoint = String.Format(endpointLocator, serviceUrl, verbTours);
            HttpWebRequest request  = CreateRequest(endPoint);

            WebResponse response       = request.GetResponse();
            Stream      responseStream = response.GetResponseStream();

            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ToursQueryResult));
            ToursQueryResult           tours      = (ToursQueryResult)serializer.ReadObject(responseStream);

            string bookmarkUrl = tours.d[0].Bookmarks[0].Url;

            // Relative URLs only
            Regex bookmarkTemplate = new Regex(@"^(/t\d+)+(/e\d+)?(/c\d+)?@?");

            Assert.IsTrue(bookmarkTemplate.IsMatch(bookmarkUrl), "Bad bookmark format: {0}", bookmarkUrl);
        }