示例#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.");
        }
        public void GetReadData_CanConvertSpecializedBooleanIfAnAttributeIsProvided_ValuesConverted(string inputData, bool expected)
        {
            // Arrange
            var attribute = new CsvConverterBooleanAttribute();

            attribute.TrueValue  = "Cat";
            attribute.FalseValue = "Frog";

            var cut = new CsvConverterDefaultBoolean();

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

            // Act
            bool actual = (bool)cut.GetReadData(typeof(bool), inputData, "Column1", 1, 1);

            // Assert
            Assert.AreEqual(expected, actual);
        }