Exemplo n.º 1
0
 public void Transform_NegativeMaxLength_ExceptionIsThrown()
 {
     var value                 = "test";
     var maxLength             = -1;
     var truncateTextAttribute = new TruncateTextAttribute(maxLength);
     var transformedValue      = truncateTextAttribute.Transform(value);
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 public void Transform_NullValue_ExceptionIsThrown()
 {
     var maxLength             = 5;
     var truncateTextAttribute = new TruncateTextAttribute(maxLength);
     var transformedValue      = truncateTextAttribute.Transform(null);
 }