Пример #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 padLeftAttribute = new PadLeftAttribute(totalWidth, paddingChar);

            padLeftAttribute.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 padLeftAttribute = new PadLeftAttribute(totalWidth, paddingChar);

            padLeftAttribute.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 padLeftAttribute = new PadLeftAttribute(totalWidth, paddingChar);

            padLeftAttribute.ApplyTransform(property, record);

            Assert.IsNull(record.StringField);
        }