public void Rejects_Null_Properties() { var properties = new [] { "Property30" }; var target = new SimpleClass { Property1 = "Property1", Property2 = 32 }; Assert.Throws <DirectDebitException>( () => Sugar.ComposeLine <SimpleClass>(SerializeMethod.FixedWidth, properties, target)); }
public void Generate_Blank_Entries() { var properties = new [] { "Property1", "Blank", "Property2" }; var target = new SimpleClass { Property1 = "Property1", Property2 = 32 }; var line = Sugar.ComposeLine <SimpleClass>(SerializeMethod.CSV, properties, target); Assert.Equal("Property1,,32", line); }
public void Escapes_Commas() { var properties = new [] { "Property1", "Property2" }; var target = new SimpleClass { Property1 = "Proper,ty1", Property2 = 32 }; var line = Sugar.ComposeLine <SimpleClass>(SerializeMethod.CSV, properties, target); Assert.Equal("\"Proper,ty1\",32", line); }
public void Properties_Are_Ordered() { var properties = new [] { "Property2", "Property1" }; var target = new SimpleClass { Property1 = "Property1", Property2 = 32 }; var line = Sugar.ComposeLine <SimpleClass>(SerializeMethod.FixedWidth, properties, target); Assert.Equal("32Property1", line); }
public void Ignores_Case() { var properties = new [] { "PROPERTY1" }; var target = new SimpleClass { Property1 = "Property1", Property2 = 32 }; var line = Sugar.ComposeLine <SimpleClass>(SerializeMethod.FixedWidth, properties, target); Assert.Equal("Property1", line); }
public void Inner_Properties() { var properties = new [] { "Property3.Property1" }; var target = new SimpleClass { Property1 = "Property1", Property2 = 32, Property3 = new InnerClass { Property1 = "Property3" } }; var line = Sugar.ComposeLine <SimpleClass>(SerializeMethod.CSV, properties, target); Assert.Equal("Property3", line); }