public void ConvertFromStringTest()
        {
            var converter = new DateTimeOffsetConverter();
            var typeConverterOptions = new TypeConverterOptions
            {
                CultureInfo = CultureInfo.CurrentCulture
            };

            var dateTime = DateTimeOffset.Now;

            // Valid conversions.
            Assert.AreEqual( dateTime.ToString(), converter.ConvertFromString( typeConverterOptions, dateTime.ToString() ).ToString() );
            Assert.AreEqual( dateTime.ToString(), converter.ConvertFromString( typeConverterOptions, dateTime.ToString( "o" ) ).ToString() );
            Assert.AreEqual( dateTime.ToString(), converter.ConvertFromString( typeConverterOptions, " " + dateTime + " " ).ToString() );

            // Invalid conversions.
            try
            {
                converter.ConvertFromString( typeConverterOptions, null );
                Assert.Fail();
            }
            catch( CsvTypeConverterException )
            {
            }
        }
        public void ConvertFromStringTest()
        {
            var converter = new DateTimeOffsetConverter();

            var propertyMapData = new CsvPropertyMapData( null );
            propertyMapData.TypeConverterOptions.CultureInfo = CultureInfo.CurrentCulture;

            var dateTime = DateTimeOffset.Now;

            // Valid conversions.
            Assert.AreEqual( dateTime.ToString(), converter.ConvertFromString( dateTime.ToString(), null, propertyMapData ).ToString() );
            Assert.AreEqual( dateTime.ToString(), converter.ConvertFromString( dateTime.ToString( "o" ), null, propertyMapData ).ToString() );
            Assert.AreEqual( dateTime.ToString(), converter.ConvertFromString( " " + dateTime + " ", null, propertyMapData ).ToString() );

            // Invalid conversions.
            try
            {
                converter.ConvertFromString( null, null, propertyMapData );
                Assert.Fail();
            }
            catch( CsvTypeConverterException )
            {
            }
        }
        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 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 ) { }
        }