Ejemplo n.º 1
0
        public void ConvertToStringTest()
        {
            var converter = new DateTimeConverter();

            var dateTime = DateTime.Now;

            // Valid conversions.
            Assert.AreEqual( dateTime.ToString(), converter.ConvertToString( dateTime ) );

            // Invalid conversions.
            Assert.AreEqual( "1", converter.ConvertToString( 1 ) );
            Assert.AreEqual( "", converter.ConvertToString( null ) );
        }
Ejemplo n.º 2
0
        public void ConvertToStringTest()
        {
            var converter = new DateTimeConverter();
            var typeConverterOptions = new TypeConverterOptions
            {
                CultureInfo = CultureInfo.CurrentCulture
            };

            var dateTime = DateTime.Now;

            // Valid conversions.
            Assert.AreEqual( dateTime.ToString(), converter.ConvertToString( typeConverterOptions, dateTime ) );

            // Invalid conversions.
            Assert.AreEqual( "1", converter.ConvertToString( typeConverterOptions, 1 ) );
            Assert.AreEqual( "", converter.ConvertToString( typeConverterOptions, null ) );
        }
Ejemplo n.º 3
0
        public void ConvertToStringTest()
        {
            var converter = new DateTimeConverter();
            var propertyMapData = new CsvPropertyMapData( null )
            {
                TypeConverter = converter,
                TypeConverterOptions = { CultureInfo = CultureInfo.CurrentCulture }
            };

            var dateTime = DateTime.Now;

            // Valid conversions.
            Assert.AreEqual( dateTime.ToString(), converter.ConvertToString( dateTime, null, propertyMapData ) );

            // Invalid conversions.
            Assert.AreEqual( "1", converter.ConvertToString( 1, null, propertyMapData ) );
            Assert.AreEqual( "", converter.ConvertToString( null, null, propertyMapData ) );
        }