Example #1
0
        public void JsonCodeGenerator_ContentResolutionForUris()
        {
            // Result will be Int,Int,DateTime
            var root = new With2Uris()
            {
                UriButString = "http://localhost",
                Uri          = new Uri("http://localhost"),
            };

            var generator  = new JsonCodeGenerator("csharp");
            var classTypes = generator.GenerateClassesTypesFromObject("Root", JsonExtensions.ToJObject(root))
                             .ToLookup(x => x.Name);

            Assert.Equal(1, classTypes.Count());


            var clazz = classTypes["Root"].Single() as JsonCodeGenerator.ClassType;

            Assert.NotNull(clazz);

            Assert.Equal("Uri", clazz.Properties["UriButString"].Name);
            Assert.False(clazz.Properties["UriButString"].IsArray);
            Assert.True(clazz.Properties["UriButString"].IsPrimitive);

            Assert.Equal("Uri", clazz.Properties["Uri"].Name);
            Assert.False(clazz.Properties["Uri"].IsArray);
            Assert.True(clazz.Properties["Uri"].IsPrimitive);
        }
        public void JsonCodeGenerator_ContentResolutionForUris()
        {
            // Result will be Int,Int,DateTime
            var root = new With2Uris()
            {
                UriButString = "http://localhost",
                Uri = new Uri("http://localhost"),
            };

            var generator = new JsonCodeGenerator("csharp");
            var classTypes = generator.GenerateClassesTypesFromObject("Root", JsonExtensions.ToJObject(root))
                                      .ToLookup(x => x.Name);

            Assert.Equal(1, classTypes.Count());

            var clazz = classTypes["Root"].Single() as JsonCodeGenerator.ClassType;
            Assert.NotNull(clazz);

            Assert.Equal("Uri", clazz.Properties["UriButString"].Name);
            Assert.False(clazz.Properties["UriButString"].IsArray);
            Assert.True(clazz.Properties["UriButString"].IsPrimitive);

            Assert.Equal("Uri", clazz.Properties["Uri"].Name);
            Assert.False(clazz.Properties["Uri"].IsArray);
            Assert.True(clazz.Properties["Uri"].IsPrimitive);
        }