public void ApplyTransform_IntField_ExceptionIsThrown() { var record = new MockRecord() { IntField = 10 }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.IntField)); var trimEndAttribute = new TrimEndAttribute(); trimEndAttribute.ApplyTransform(property, record); }
public void ApplyTransform_StringFieldWithSpacesOnLeftAndRight_TextIsTrimmedAtEnd() { var record = new MockRecord() { StringField = " test " }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var trimEndAttribute = new TrimEndAttribute(); trimEndAttribute.ApplyTransform(property, record); Assert.AreEqual(" test", record.StringField); }
public void ApplyTransform_StringFieldWithOnlySpaces_ValueIsTrimmedToEmpty() { var record = new MockRecord() { StringField = " " }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var trimEndAttribute = new TrimEndAttribute(); trimEndAttribute.ApplyTransform(property, record); Assert.AreEqual("", record.StringField); }
public void ApplyTransform_StringFieldWithNullValue_ValueIsUnchanged() { var record = new MockRecord() { StringField = null }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var trimEndAttribute = new TrimEndAttribute(); trimEndAttribute.ApplyTransform(property, record); Assert.IsNull(record.StringField); }
public void ApplyTransform_StringFieldWithCustomTrimCharsOnLeftAndRight_TextIsTrimmed() { var trimChars = new char[] { 'X', 'Y' }; var record = new MockRecord() { StringField = "XYtestXY" }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var trimEndAttribute = new TrimEndAttribute(trimChars); trimEndAttribute.ApplyTransform(property, record); Assert.AreEqual("XYtest", record.StringField); }