public void ComponentModelCompatibilityTest() { var converter = new DateTimeOffsetConverter(); var cmConverter = new System.ComponentModel.DateTimeOffsetConverter(); var propertyMapData = new MemberMapData(null); propertyMapData.TypeConverterOptions.CultureInfo = CultureInfo.CurrentCulture; var row = new CsvReader(new ParserMock()); Assert.ThrowsException <NotSupportedException>(() => cmConverter.ConvertFromString(null)); Assert.ThrowsException <TypeConverterException>(() => converter.ConvertFromString(null, row, propertyMapData)); Assert.ThrowsException <FormatException>(() => cmConverter.ConvertFromString("blah")); Assert.ThrowsException <FormatException>(() => converter.ConvertFromString("blah", row, propertyMapData)); }
public void ComponentModelCompatibilityTest() { var converter = new DateTimeOffsetConverter(); var cmConverter = new System.ComponentModel.DateTimeOffsetConverter(); var propertyMapData = new CsvPropertyMapData( null ); propertyMapData.TypeConverterOptions.CultureInfo = CultureInfo.CurrentCulture; try { cmConverter.ConvertFromString( null ); Assert.Fail(); } catch( NotSupportedException ) { } try { converter.ConvertFromString( null, null, propertyMapData ); Assert.Fail(); } catch( CsvTypeConverterException ) { } try { cmConverter.ConvertFromString( "blah" ); Assert.Fail(); } catch( FormatException ) { } try { converter.ConvertFromString( "blah", null, propertyMapData ); } catch( FormatException ) { } }
public void ComponentModelCompatibilityTest() { var converter = new DateTimeOffsetConverter(); var cmConverter = new System.ComponentModel.DateTimeOffsetConverter(); var typeConverterOptions = new TypeConverterOptions { CultureInfo = CultureInfo.CurrentCulture }; var val = (DateTimeOffset)cmConverter.ConvertFromString(""); Assert.AreEqual(DateTimeOffset.MinValue, val); val = (DateTimeOffset)converter.ConvertFromString(typeConverterOptions, ""); Assert.AreEqual(DateTimeOffset.MinValue, val); try { cmConverter.ConvertFromString(null); Assert.Fail(); } catch (NotSupportedException) { } try { converter.ConvertFromString(typeConverterOptions, null); Assert.Fail(); } catch (CsvTypeConverterException) { } try { cmConverter.ConvertFromString("blah"); Assert.Fail(); } catch (FormatException) { } try { converter.ConvertFromString(typeConverterOptions, "blah"); } catch (FormatException) { } }
public void ComponentModelCompatibilityTest() { var converter = new DateTimeOffsetConverter(); var cmConverter = new System.ComponentModel.DateTimeOffsetConverter(); var typeConverterOptions = new TypeConverterOptions { CultureInfo = CultureInfo.CurrentCulture }; var val = (DateTimeOffset)cmConverter.ConvertFromString( "" ); Assert.AreEqual( DateTimeOffset.MinValue, val ); val = (DateTimeOffset)converter.ConvertFromString( typeConverterOptions, "" ); Assert.AreEqual( DateTimeOffset.MinValue, val ); try { cmConverter.ConvertFromString( null ); Assert.Fail(); } catch( NotSupportedException ) { } try { converter.ConvertFromString( typeConverterOptions, null ); Assert.Fail(); } catch( CsvTypeConverterException ) { } try { cmConverter.ConvertFromString( "blah" ); Assert.Fail(); } catch( FormatException ) { } try { converter.ConvertFromString( typeConverterOptions, "blah" ); } catch( FormatException ) { } }
public void ComponentModelCompatibilityTest() { var converter = new DateTimeOffsetConverter(); var cmConverter = new System.ComponentModel.DateTimeOffsetConverter(); var propertyMapData = new MemberMapData(null); propertyMapData.TypeConverterOptions.CultureInfo = CultureInfo.CurrentCulture; var mockRow = new Mock <IReaderRow>(); try { cmConverter.ConvertFromString(null); Assert.Fail(); } catch (NotSupportedException) { } try { converter.ConvertFromString(null, mockRow.Object, propertyMapData); Assert.Fail(); } catch (TypeConverterException) { } try { cmConverter.ConvertFromString("blah"); Assert.Fail(); } catch (FormatException) { } try { converter.ConvertFromString("blah", mockRow.Object, propertyMapData); } catch (FormatException) { } }
public void ComponentModelCompatibilityTest() { var converter = new DateTimeOffsetConverter(); var cmConverter = new System.ComponentModel.DateTimeOffsetConverter(); var propertyMapData = new CsvPropertyMapData(null); propertyMapData.TypeConverterOptions.CultureInfo = CultureInfo.CurrentCulture; try { cmConverter.ConvertFromString(null); Assert.Fail(); } catch (NotSupportedException) { } try { converter.ConvertFromString(null, null, propertyMapData); Assert.Fail(); } catch (CsvTypeConverterException) { } try { cmConverter.ConvertFromString("blah"); Assert.Fail(); } catch (FormatException) { } try { converter.ConvertFromString("blah", null, propertyMapData); } catch (FormatException) { } }