Beispiel #1
0
        public void ConvertCurrency()
        {
            var format = new ValueFormat( typeof( double ), "000000.00", new Regex( @"([\d.]+)\s*€" ) );

            double value = (double)format.Convert( "2.5€" );
            Assert.AreEqual( 2.5, value, 0.000001d );

            value = (double)format.Convert( "0.25 €" );
            Assert.AreEqual( 0.25, value, 0.000001d );
        }
Beispiel #2
0
        public void ConvertCurrency()
        {
            var format = new ValueFormat(typeof(double), "000000.00", new Regex(@"([\d.]+)\s*€"));

            double value = (double)format.Convert("2.5€");

            Assert.AreEqual(2.5, value, 0.000001d);

            value = (double)format.Convert("0.25 €");
            Assert.AreEqual(0.25, value, 0.000001d);
        }
Beispiel #3
0
        public void ConvertString()
        {
            var    format = new ValueFormat(typeof(string));
            object value  = format.Convert("hiho");

            Assert.AreEqual("hiho", value);
        }
Beispiel #4
0
        public void ConvertDoubleWithoutFormat()
        {
            var    format = new ValueFormat(typeof(double));
            object value  = format.Convert("2.5");

            Assert.IsFalse(value is double);
        }
Beispiel #5
0
        public void ConvertDouble()
        {
            var    format = new ValueFormat(typeof(double), "00.00");
            double value  = (double)format.Convert("2.5");

            Assert.AreEqual(2.5, value);
        }
Beispiel #6
0
        public void ConvertRegExString()
        {
            var    format = new ValueFormat(typeof(int), "000000", new Regex(@"WKN: ([\d]+)"));
            object value  = format.Convert("WKN: 850206");

            Assert.AreEqual(850206, (int)value);
        }
Beispiel #7
0
        public void ConvertString()
        {
            var format = new ValueFormat();
            object value = format.Convert( "hiho" );

            Assert.AreEqual( "hiho", value );
        }
Beispiel #8
0
        public void ConvertRegExString()
        {
            var format = new ValueFormat( typeof( int ), "000000", new Regex( @"WKN: ([\d]+)" ) );
            object value = format.Convert( "WKN: 850206" );

            Assert.AreEqual( 850206, (int)value );
        }
Beispiel #9
0
        public void ConvertdoubleWithoutFormat()
        {
            var format = new ValueFormat( typeof( double ) );
            object value = format.Convert( "2.5" );

            Assert.IsFalse( value is double );
        }
Beispiel #10
0
        public void ConvertDouble()
        {
            var format = new ValueFormat( typeof( double ), "00.00" );
            double value = (double)format.Convert( "2.5" );

            Assert.AreEqual( 2.5, value );
        }
Beispiel #11
0
        public void ConvertDateTime()
        {
            var      format = new ValueFormat(typeof(DateTime), "dd.MM.yyyy");
            DateTime value  = (DateTime)format.Convert("12.12.2000");

            Assert.AreEqual(2000, value.Year);
            Assert.AreEqual(12, value.Month);
            Assert.AreEqual(12, value.Day);
        }
Beispiel #12
0
        public void ConvertDateTime()
        {
            var format = new ValueFormat( typeof( DateTime ), "dd.MM.yyyy" );
            DateTime value = (DateTime)format.Convert( "12.12.2000" );

            Assert.AreEqual( 2000, value.Year );
            Assert.AreEqual( 12, value.Month );
            Assert.AreEqual( 12, value.Day );
        }
Beispiel #13
0
        public void Convert_InMillions_ValueMultipliedByOneMillion()
        {
            var format = new ValueFormat(typeof(double), "00.00");

            format.InMillions = true;

            double value = (double)format.Convert("2.5");

            Assert.That(value, Is.EqualTo(2.5 * 1000000));
        }