Esempio n. 1
0
        public void JsonCodeGenerator_WithArrayOfFloats()
        {
            var root = new WithArrayOfFloats()
            {
                Floats = new List <float>
                {
                    -1.0f,
                    +1.0f,
                }
            };

            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("float", clazz.Properties["Floats"].Name);
            Assert.True(clazz.Properties["Floats"].IsArray);
            Assert.True(clazz.Properties["Floats"].IsPrimitive);
        }
Esempio n. 2
0
        public void JsonCodeGenerator_WithArrayOfFloatsGenerator()
        {
            var root = new WithArrayOfFloats()
            {
                Floats = new List <float>
                {
                    -1.0f,
                    +1.0f,
                }
            };

            var document = new JsonDocument()
            {
                DataAsJson = JsonExtensions.ToJObject(root)
            };

            var generator = new JsonCodeGenerator("csharp");
            var code      = generator.Execute(document);

            Assert.Contains("public class Class", code);
            Assert.Contains("public float[] Floats { get; set; }", code);
        }
Esempio n. 3
0
        public void JsonCodeGenerator_WithArrayOfFloatsGenerator()
        {
            var root = new WithArrayOfFloats()
            {
                Floats = new List<float>
                {
                     -1.0f,
                     +1.0f,
                }
            };

            var document = new JsonDocument()
            {
                DataAsJson = JsonExtensions.ToJObject(root)
            };

            var generator = new JsonCodeGenerator("csharp");
            var code = generator.Execute(document);

            Assert.Contains("public class Class", code);
            Assert.Contains("public float[] Floats { get; set; }", code);
        }
Esempio n. 4
0
        public void JsonCodeGenerator_WithArrayOfFloats()
        {
            var root = new WithArrayOfFloats()
            {
                Floats = new List<float>
                {
                     -1.0f,
                     +1.0f,
                }
            };

            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("float", clazz.Properties["Floats"].Name);
            Assert.True(clazz.Properties["Floats"].IsArray);
            Assert.True(clazz.Properties["Floats"].IsPrimitive);
        }