public void Transform_NullValue_ExceptionIsThrown() { var oldValue = "A"; var newValue = "B"; var replaceTextAttribute = new ReplaceTextAttribute(oldValue, newValue); var transformedValue = replaceTextAttribute.Transform(null); }
public void Transform_ValueWithTextToReplaceAndOldValueIsNull_ExceptionIsThrown() { var value = "ABC"; var oldValue = (string)null; var newValue = "B"; var replaceTextAttribute = new ReplaceTextAttribute(oldValue, newValue); var transformedValue = replaceTextAttribute.Transform(value); }
public void Transform_ValueWithTextToReplace_OriginalValueWithTextReplacedReturned() { var value = "ABC"; var oldValue = "A"; var newValue = "B"; var replaceTextAttribute = new ReplaceTextAttribute(oldValue, newValue); var transformedValue = replaceTextAttribute.Transform(value); Assert.AreEqual("BBC", transformedValue); }
public void ApplyTransform_NonStringField_ExceptionIsThrown() { var record = new MockRecord() { IntField = 1 }; var oldValue = "A"; var newValue = "X"; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.IntField)); var replaceTextAttribute = new ReplaceTextAttribute(oldValue, newValue); replaceTextAttribute.ApplyTransform(property, record); }
public void ApplyTransform_OldValueExistsAndSameLengthAsReplacement_TextIsReplaced() { var record = new MockRecord() { StringField = "ABC" }; var oldValue = "A"; var newValue = "X"; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var replaceTextAttribute = new ReplaceTextAttribute(oldValue, newValue); replaceTextAttribute.ApplyTransform(property, record); Assert.AreEqual("XBC", record.StringField); }
public void ApplyTransform_OldValueExistsMultipleTimes_TextIsReplaced() { var record = new MockRecord() { StringField = "ABACA" }; var oldValue = "A"; var newValue = "X"; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var replaceTextAttribute = new ReplaceTextAttribute(oldValue, newValue); replaceTextAttribute.ApplyTransform(property, record); Assert.AreEqual("XBXCX", record.StringField); }
public void ApplyTransform_OldValueDoesNotExist_ValueIsUnchanged() { var record = new MockRecord() { StringField = "ABC" }; var oldValue = "X"; var newValue = "Y"; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var replaceTextAttribute = new ReplaceTextAttribute(oldValue, newValue); replaceTextAttribute.ApplyTransform(property, record); Assert.AreEqual("ABC", record.StringField); }
public void ApplyTransform_NullValue_ValueIsUnchanged() { var record = new MockRecord() { StringField = null }; var oldValue = "A"; var newValue = "X"; var property = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField)); var replaceTextAttribute = new ReplaceTextAttribute(oldValue, newValue); replaceTextAttribute.ApplyTransform(property, record); Assert.IsNull(record.StringField); }