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); }
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); }
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); }
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); }