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 ); }
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); }
public void ConvertString() { var format = new ValueFormat(typeof(string)); object value = format.Convert("hiho"); Assert.AreEqual("hiho", value); }
public void ConvertDoubleWithoutFormat() { var format = new ValueFormat(typeof(double)); object value = format.Convert("2.5"); Assert.IsFalse(value is double); }
public void ConvertDouble() { var format = new ValueFormat(typeof(double), "00.00"); double value = (double)format.Convert("2.5"); Assert.AreEqual(2.5, value); }
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); }
public void ConvertString() { var format = new ValueFormat(); object value = format.Convert( "hiho" ); Assert.AreEqual( "hiho", value ); }
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 ); }
public void ConvertdoubleWithoutFormat() { var format = new ValueFormat( typeof( double ) ); object value = format.Convert( "2.5" ); Assert.IsFalse( value is double ); }
public void ConvertDouble() { var format = new ValueFormat( typeof( double ), "00.00" ); double value = (double)format.Convert( "2.5" ); Assert.AreEqual( 2.5, value ); }
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); }
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 ); }
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)); }