Example #1
0
        private static void TestParameterIs(DecimalParameter p, decimal val)
        {
            Assert.That(p.Value, Is.EqualTo(val));
            decimal result;
            bool    isInt;

            Assert.That(p.Corrupted, Is.False);
            Assert.That(p.ValueAsString(), Is.EqualTo(val.ToString(CultureInfo.InvariantCulture))); //Tempting to simply verify it will parse as the correct value but we need to be consistent with existing files
            using (TemporaryCulture.English())
            {
                isInt = decimal.TryParse(p.DisplayValue((a, b) => ""), NumberStyles.Any, CultureInfo.InvariantCulture, out result);
                Assert.That(isInt);
                if (isInt)
                {
                    Assert.That(result, Is.EqualTo(val));
                }
            }
            using (TemporaryCulture.European())
            {
                isInt = decimal.TryParse(p.DisplayValue((a, b) => ""), NumberStyles.Any, CultureInfo.CurrentCulture, out result);
                Assert.That(isInt);
                if (isInt)
                {
                    Assert.That(result, Is.EqualTo(val));
                }
            }
        }
Example #2
0
 private static void TestCorruptParameter(DecimalParameter p, string valueAsString)
 {
     Assert.That(p.Corrupted, Is.True);
     Assert.That(p.ValueAsString(), Is.EqualTo(valueAsString));
 }