public void ConvertFromStringTest() { var converter = new EnumConverter( typeof( TestEnum ) ); var typeConverterOptions = new TypeConverterOptions { CultureInfo = CultureInfo.CurrentCulture }; Assert.AreEqual( TestEnum.One, converter.ConvertFromString( typeConverterOptions, "One" ) ); Assert.AreEqual( TestEnum.One, converter.ConvertFromString( typeConverterOptions, "one" ) ); Assert.AreEqual( TestEnum.One, converter.ConvertFromString( typeConverterOptions, "1" ) ); try { Assert.AreEqual( TestEnum.One, converter.ConvertFromString( typeConverterOptions, "" ) ); Assert.Fail(); } catch( CsvTypeConverterException ) { } try { Assert.AreEqual( TestEnum.One, converter.ConvertFromString( typeConverterOptions, null ) ); Assert.Fail(); } catch( CsvTypeConverterException ) { } }
public void ConvertFromStringTest() { var converter = new EnumConverter( typeof( TestEnum ) ); Assert.AreEqual( TestEnum.One, converter.ConvertFromString( "One" ) ); Assert.AreEqual( TestEnum.One, converter.ConvertFromString( "one" ) ); Assert.AreEqual( TestEnum.One, converter.ConvertFromString( "1" ) ); try { Assert.AreEqual( TestEnum.One, converter.ConvertFromString( "" ) ); Assert.Fail(); } catch( NotSupportedException ) { } try { Assert.AreEqual( TestEnum.One, converter.ConvertFromString( null ) ); Assert.Fail(); } catch( NotSupportedException ) { } }