public void Initialize_PassingInTheWrongTypeOfAttributeToThePostConverter_ResultsInException() { // Arrange var attribute = new CsvConverterBooleanAttribute(typeof(CsvConverterStringReplaceTextExactMatch)); var classUnderTest = new CsvConverterStringReplaceTextExactMatch(); classUnderTest.Initialize(attribute, new DefaultTypeConverterFactory()); // Assert Assert.Fail("Should have received an exception for passing in wrong type of attribute."); }
[DataRow("Cat", "cat", "bat", false, "bat")] // IsCaseSensitive now false so match! public void GetReadData_CanReplaceText_DataReplaced(string csvField, string oldValue, string newValue, bool isCaseSensitive, string expectedResult) { // Arrange var attribute = new CsvConverterStringOldAndNewAttribute( typeof(CsvConverterStringReplaceTextExactMatch)) { OldValue = oldValue, NewValue = newValue, IsCaseSensitive = isCaseSensitive }; var classUnderTest = new CsvConverterStringReplaceTextExactMatch(); classUnderTest.Initialize(attribute, new DefaultTypeConverterFactory()); // Act object actualResult = classUnderTest.GetReadData(typeof(string), csvField, "Column1", 1, 1); // Assert Assert.AreEqual(expectedResult, actualResult); }