public void GetReadData_CanConvertNonNullableBooleansWithoutAnAttribute_ValuesConverted(string inputData, bool expected) { // Arrange var cut = new CsvConverterDefaultBoolean(); cut.Initialize(null, new DefaultTypeConverterFactory()); // Act bool actual = (bool)cut.GetReadData(typeof(bool), inputData, "Column1", 1, 1); // Assert Assert.AreEqual(expected, actual); }
public void GetReadData_CanHandleNonIntegerStrings_ThrowsException(string inputData) { // Arrange var cut = new CsvConverterDefaultBoolean(); cut.Initialize(null, new DefaultTypeConverterFactory()); // Act bool actual = (bool)cut.GetReadData(typeof(bool), inputData, "Column1", 1, 1); // Assert Assert.Fail("Exception should be thrown when invalid values are passed into the parser!"); }
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); }