public void Transform_NegativeMaxLength_ExceptionIsThrown() { var value = "test"; var maxLength = -1; var truncateTextAttribute = new TruncateTextAttribute(maxLength); var transformedValue = truncateTextAttribute.Transform(value); }
public void Transform_TextOverMaxLength_TruncatedTextReturned() { var value = "123456"; var maxLength = 5; var truncateTextAttribute = new TruncateTextAttribute(maxLength); var transformedValue = truncateTextAttribute.Transform(value); Assert.AreEqual("12345", transformedValue); }
public void Transform_ZeroMaxLength_EmptyStringReturned() { var value = "test"; var maxLength = 0; var truncateTextAttribute = new TruncateTextAttribute(maxLength); var transformedValue = truncateTextAttribute.Transform(value); Assert.AreEqual(String.Empty, transformedValue); }
public void Transform_TextUnderMaxLength_OriginalTextReturned() { var value = "123"; var maxLength = 5; var truncateTextAttribute = new TruncateTextAttribute(maxLength); var transformedValue = truncateTextAttribute.Transform(value); Assert.AreEqual("123", transformedValue); }
public void ApplyTransform_IntField_ExceptionIsThrown() { var maxLength = 5; var record = new MockRecord() { IntField = 10 }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.IntField)); var truncateTextAttribute = new TruncateTextAttribute(maxLength); truncateTextAttribute.ApplyTransform(property, record); }
public void ApplyTransform_StringFieldWithValueOverMaxLength_TextIsTruncated() { var maxLength = 5; var record = new MockRecord() { StringField = "123456789" }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var truncateTextAttribute = new TruncateTextAttribute(maxLength); truncateTextAttribute.ApplyTransform(property, record); Assert.AreEqual("12345", record.StringField); }
public void ApplyTransform_StringFieldWithNullValue_ValueIsUnchanged() { var maxLength = 5; var record = new MockRecord() { StringField = null }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var truncateTextAttribute = new TruncateTextAttribute(maxLength); truncateTextAttribute.ApplyTransform(property, record); Assert.IsNull(record.StringField); }
public void Transform_NullValue_ExceptionIsThrown() { var maxLength = 5; var truncateTextAttribute = new TruncateTextAttribute(maxLength); var transformedValue = truncateTextAttribute.Transform(null); }