예제 #1
0
        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 padRightAttribute = new PadRightAttribute(totalWidth, paddingChar);

            padRightAttribute.ApplyTransform(property, record);
        }
예제 #2
0
        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 padRightAttribute = new PadRightAttribute(totalWidth, paddingChar);

            padRightAttribute.ApplyTransform(property, record);

            Assert.AreEqual("ABC  ", record.StringField);
        }
예제 #3
0
        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 padRightAttribute = new PadRightAttribute(totalWidth, paddingChar);

            padRightAttribute.ApplyTransform(property, record);

            Assert.IsNull(record.StringField);
        }