Exemplo n.º 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 );
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public void ConvertString()
        {
            var    format = new ValueFormat(typeof(string));
            object value  = format.Convert("hiho");

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

            Assert.IsFalse(value is double);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
        public void ConvertString()
        {
            var format = new ValueFormat();
            object value = format.Convert( "hiho" );

            Assert.AreEqual( "hiho", value );
        }
Exemplo n.º 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 );
        }
Exemplo n.º 9
0
        public void ConvertdoubleWithoutFormat()
        {
            var format = new ValueFormat( typeof( double ) );
            object value = format.Convert( "2.5" );

            Assert.IsFalse( value is double );
        }
Exemplo n.º 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 );
        }
Exemplo n.º 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);
        }
Exemplo n.º 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 );
        }
Exemplo n.º 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));
        }