Example #1
0
        private static void TestParameterIs(BooleanParameter p, bool val, string valueAsString = null)
        {
            Assert.That(p.Value, Is.EqualTo(val));
            bool result;
            bool isBool;

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