public void ApplyTransform_NonStringField_ExceptionIsThrown() { var record = new MockRecord() { IntField = 1 }; var totalWidth = 5; var paddingChar = ' '; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.IntField)); var padLeftAttribute = new PadLeftAttribute(totalWidth, paddingChar); padLeftAttribute.ApplyTransform(property, record); }
public void ApplyTransform_NonEmptyValueUnderTotalWidth_ValueIsPadded() { var record = new MockRecord() { StringField = "ABC" }; var totalWidth = 5; var paddingChar = ' '; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var padLeftAttribute = new PadLeftAttribute(totalWidth, paddingChar); padLeftAttribute.ApplyTransform(property, record); Assert.AreEqual(" ABC", record.StringField); }
public void ApplyTransform_NullValue_ValueIsUnchanged() { var record = new MockRecord() { StringField = null }; var totalWidth = 5; var paddingChar = ' '; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var padLeftAttribute = new PadLeftAttribute(totalWidth, paddingChar); padLeftAttribute.ApplyTransform(property, record); Assert.IsNull(record.StringField); }