Ejemplo n.º 1
0
        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 ) );
        }
Ejemplo n.º 2
0
        public void ConvertToStringTest()
        {
            var converter = new CharConverter();

            Assert.AreEqual( "a", converter.ConvertToString( 'a' ) );

            Assert.AreEqual( "True", converter.ConvertToString( true ) );

            Assert.AreEqual( "", converter.ConvertToString( null ) );
        }
Ejemplo n.º 3
0
        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 ) );
        }
Ejemplo n.º 4
0
		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 ) );
		}
Ejemplo n.º 5
0
        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 ) );
        }
Ejemplo n.º 6
0
        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 )
            {
            }
        }
Ejemplo n.º 7
0
        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 )
            {
            }
        }
Ejemplo n.º 8
0
        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 )
            {
            }
        }