public void ConvertFromStringTest() { var converter = new CharConverter(); Assert.Equal( 'a', converter.ConvertFromString( "a" ) ); Assert.Equal( 'a', converter.ConvertFromString( " a " ) ); Assert.Throws<NotSupportedException>( () => converter.ConvertFromString( null ) ); }
public void ConvertToStringTest() { var converter = new CharConverter(); Assert.AreEqual( "a", converter.ConvertToString( 'a' ) ); Assert.AreEqual( "True", converter.ConvertToString( true ) ); Assert.AreEqual( "", converter.ConvertToString( null ) ); }
public void ConvertToStringTest() { var converter = new CharConverter(); Assert.AreEqual( "a", converter.ConvertToString( CultureInfo.CurrentCulture, 'a' ) ); Assert.AreEqual( "True", converter.ConvertToString( CultureInfo.CurrentCulture, true ) ); Assert.AreEqual( "", converter.ConvertToString( CultureInfo.CurrentCulture, null ) ); }
public void ConvertToStringTest() { var converter = new CharConverter(); var typeConverterOptions = new TypeConverterOptions { CultureInfo = CultureInfo.CurrentCulture }; Assert.AreEqual( "a", converter.ConvertToString( typeConverterOptions, 'a' ) ); Assert.AreEqual( "True", converter.ConvertToString( typeConverterOptions, true ) ); Assert.AreEqual( "", converter.ConvertToString( typeConverterOptions, null ) ); }
public void ConvertToStringTest() { var converter = new CharConverter(); var propertyMapData = new CsvPropertyMapData( null ) { TypeConverter = converter, TypeConverterOptions = { CultureInfo = CultureInfo.CurrentCulture } }; Assert.AreEqual( "a", converter.ConvertToString( 'a', null, propertyMapData ) ); Assert.AreEqual( "True", converter.ConvertToString( true, null, propertyMapData ) ); Assert.AreEqual( "", converter.ConvertToString( null, null, propertyMapData ) ); }
public void ConvertFromStringTest() { var converter = new CharConverter(); Assert.AreEqual( 'a', converter.ConvertFromString( "a" ) ); Assert.AreEqual( 'a', converter.ConvertFromString( " a " ) ); try { converter.ConvertFromString( null ); Assert.Fail(); } catch( NotSupportedException ) { } }
public void ConvertFromStringTest() { var converter = new CharConverter(); Assert.AreEqual( 'a', converter.ConvertFromString( CultureInfo.CurrentCulture, "a" ) ); Assert.AreEqual( 'a', converter.ConvertFromString( CultureInfo.CurrentCulture, " a " ) ); try { converter.ConvertFromString( CultureInfo.CurrentCulture, null ); Assert.Fail(); } catch( CsvTypeConverterException ) { } }
public void ConvertFromStringTest() { var converter = new CharConverter(); var propertyMapData = new CsvPropertyMapData( null ); propertyMapData.TypeConverterOptions.CultureInfo = CultureInfo.CurrentCulture; Assert.AreEqual( 'a', converter.ConvertFromString( "a", null, propertyMapData ) ); Assert.AreEqual( 'a', converter.ConvertFromString( " a ", null, propertyMapData ) ); Assert.AreEqual( ' ', converter.ConvertFromString( " ", null, propertyMapData ) ); try { converter.ConvertFromString( null, null, propertyMapData ); Assert.Fail(); } catch( CsvTypeConverterException ) { } }