public void Then_xml_should_be_valid()
        {
            var dynamicXml   = ConvertDynamic.ToXml(dynamic, "animals");
            var originalXml  = XElement.Parse(xml);
            var convertedXml = XElement.Parse(dynamicXml);

            Assert.AreEqual(originalXml.ToString(), convertedXml.ToString());
        }
Ejemplo n.º 2
0
        public void Then_json_should_be_valid()
        {
            var correctJson =
                "{\"badger\":{\"name\":\"Steve\",\"age\":3},\"dog\":[{\"name\":\"Rufus\",\"breed\":\"labrador\"},{\"name\":\"Marty\",\"breed\":\"whippet\"}],\"cat\":{\"name\":\"Matilda\"}}";
            var json = ConvertDynamic.ToJson(dynamic);

            Console.WriteLine(json);
            Assert.AreEqual(correctJson, json);
        }
Ejemplo n.º 3
0
        public void Then_movie_should_be_inserted_using_json()
        {
            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            dynamic movie = new ExpandoObject();

            movie.Title       = "The Muppets Take Manhattan";
            movie.TagLine     = "tagline";
            movie.Rating      = 6.7;
            movie.ImdbId      = "tt0087755";
            movie.Director    = "Frank Oz";
            movie.ReleaseDate = new DateTime(1986, 2, 15);
            var json = ConvertDynamic.ToJson(movie);

            client.UploadString("http://www.servicestack.net/ServiceStack.MovieRest/movies", json);
            var     response = client.DownloadString("http://www.servicestack.net/ServiceStack.MovieRest/movies?format=json");
            dynamic dynamic  = response.ToDynamic();

            dynamic[] movies = dynamic.Movies;
            string    title  = movies.Last().Title;

            Assert.AreEqual("The Muppets Take Manhattan", title);
        }