Пример #1
0
        public void Initialize_PassingInTheWrongTypeOfAttributeToThePostConverter_ResultsInException()
        {
            // Arrange
            var attribute      = new CsvConverterBooleanAttribute(typeof(CsvConverterStringReplaceTextEveryMatch));
            var classUnderTest = new CsvConverterStringReplaceTextEveryMatch();

            classUnderTest.Initialize(attribute, new DefaultTypeConverterFactory());

            // Assert
            Assert.Fail("Should have received an exception for passing in wrong type of attribute.");
        }
Пример #2
0
        public void GetReadData_CanReplaceText_DataReplaced(string csvField, string oldValue,
                                                            string newValue, bool isCaseSensitive, string expectedResult)
        {
            // Arrange
            var attribute = new CsvConverterStringOldAndNewAttribute(
                typeof(CsvConverterStringReplaceTextEveryMatch))
            {
                OldValue = oldValue, NewValue = newValue, IsCaseSensitive = isCaseSensitive
            };

            var classUnderTest = new CsvConverterStringReplaceTextEveryMatch();

            classUnderTest.Initialize(attribute, new DefaultTypeConverterFactory());

            // Act
            object actualResult = classUnderTest.GetReadData(typeof(string), csvField, "Column1", 1, 1);

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }