public void Format_TransformStringAttributeThrowsException_ExceptionIsPropogated() { var record = new MockRecord() { StringFieldWithErroredTransformStringAttribute = "test" }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringFieldWithErroredTransformStringAttribute)); var formatter = new TextRecordFieldFormatter(); var formattedValue = formatter.Format(record.StringFieldWithErroredTransformStringAttribute, property); }
public void Format_NullStringFieldWithTransformAttribute_FormattedValueIsNull() { var record = new MockRecord() { StringFieldWithTransformAttribute = null }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringFieldWithTransformAttribute)); var formatter = new TextRecordFieldFormatter(); var formattedValue = formatter.Format(record.StringFieldWithTransformAttribute, property); Assert.IsNull(formattedValue); }
public void Format_StringFieldWithNoAttributes_FieldIsNotFormatted() { var record = new MockRecord() { StringField = "test" }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var formatter = new TextRecordFieldFormatter(); var formattedValue = formatter.Format(record.StringField, property); Assert.AreEqual(record.StringField, formattedValue); }
public void Format_NullStringFieldWithToStringAndTransformAttributes_FieldIsConvertedToStringViaAttributeAndFormatted() { var record = new MockRecord() { StringFieldWithToStringAndTransformAttributes = null }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringFieldWithToStringAndTransformAttributes)); var formatter = new TextRecordFieldFormatter(); var formattedValue = formatter.Format(record.StringFieldWithToStringAndTransformAttributes, property); Assert.AreEqual($"|''|", formattedValue); }
public void Format_EmptyStringFieldWithToStringAttribute_FieldIsConvertedToStringViaAttribute() { var record = new MockRecord() { StringFieldWithToStringAttribute = String.Empty }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringFieldWithToStringAttribute)); var formatter = new TextRecordFieldFormatter(); var formattedValue = formatter.Format(record.StringFieldWithToStringAttribute, property); Assert.AreEqual($"'{record.StringFieldWithToStringAttribute}'", formattedValue); }
public void Format_NullNullableIntFieldWithNullableTransformAttribute_FieldIsFormatted() { var record = new MockRecord() { NullableIntFieldWithNullableTransformAttribute = null }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.NullableIntFieldWithNullableTransformAttribute)); var formatter = new TextRecordFieldFormatter(); var formattedValue = formatter.Format(record.NullableIntFieldWithNullableTransformAttribute, property); Assert.AreEqual($"|NULL|", formattedValue); }
public void Format_NonNullOrEmptyNullableIntFieldWithToStringAndTransformAttributes_FieldIsConvertedToStringViaAttributeAndFormatted() { var record = new MockRecord() { NullableIntFieldWithToStringAndTransformAttributes = 10 }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.NullableIntFieldWithToStringAndTransformAttributes)); var formatter = new TextRecordFieldFormatter(); var formattedValue = formatter.Format(record.NullableIntFieldWithToStringAndTransformAttributes, property); Assert.AreEqual($"|'{record.NullableIntFieldWithToStringAndTransformAttributes}'|", formattedValue); }
public void Format_NullableIntFieldWithNoAttributes_FieldIsConvertedToStringAndNotFormatted() { var record = new MockRecord() { NullableIntField = 10 }; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.NullableIntField)); var formatter = new TextRecordFieldFormatter(); var formattedValue = formatter.Format(record.NullableIntField, property); Assert.AreEqual("10", formattedValue); }