public void ConvertTest()
        {
            var converter = new EnumerableConverter();

            var propertyMapData = new CsvPropertyMapData(null);

            propertyMapData.TypeConverterOptions.CultureInfo = CultureInfo.CurrentCulture;

            try
            {
                converter.ConvertFromString("", null, propertyMapData);
                Assert.Fail();
            }
            catch (CsvTypeConverterException)
            {
            }
            try
            {
                converter.ConvertToString(5, null, propertyMapData);
                Assert.Fail();
            }
            catch (CsvTypeConverterException)
            {
            }
        }
        public void ConvertTest()
        {
            var converter            = new EnumerableConverter();
            var typeConverterOptions = new TypeConverterOptions
            {
                CultureInfo = CultureInfo.CurrentCulture
            };

            Assert.IsTrue(converter.CanConvertFrom(typeof(string)));
            Assert.IsTrue(converter.CanConvertTo(typeof(string)));
            try
            {
                converter.ConvertFromString(typeConverterOptions, "");
                Assert.Fail();
            }
            catch (CsvTypeConverterException)
            {
            }
            try
            {
                converter.ConvertToString(typeConverterOptions, 5);
                Assert.Fail();
            }
            catch (CsvTypeConverterException)
            {
            }
        }
Beispiel #3
0
        public void ConvertTest()
        {
            var converter = new EnumerableConverter();

            var propertyMapData = new MemberMapData(null);

            propertyMapData.TypeConverterOptions.CultureInfo = CultureInfo.CurrentCulture;

            var mockReaderRow = new Mock <IReaderRow>();
            var mockWriterRow = new Mock <IWriterRow>();

            try
            {
                converter.ConvertFromString("", mockReaderRow.Object, propertyMapData);
                Assert.Fail();
            }
            catch (TypeConverterException)
            {
            }
            try
            {
                converter.ConvertToString(5, mockWriterRow.Object, propertyMapData);
                Assert.Fail();
            }
            catch (TypeConverterException)
            {
            }
        }
Beispiel #4
0
        public void ConvertTest()
        {
            var converter = new EnumerableConverter();

            var propertyMapData = new MemberMapData(null);

            propertyMapData.TypeConverterOptions.CultureInfo = CultureInfo.CurrentCulture;

            var readerRow = new CsvReader(new ParserMock());
            var writerRow = new CsvWriter(new StringWriter(), CultureInfo.InvariantCulture);

            Assert.Throws <TypeConverterException>(() => converter.ConvertFromString("", readerRow, propertyMapData));
            Assert.Throws <TypeConverterException>(() => converter.ConvertToString(5, writerRow, propertyMapData));
        }