public void DoubleCtor()
 {
     Percentage percentage = new Percentage(0.567);
     Assert.AreEqual(0.567, percentage.Value);
     Assert.AreEqual(0.567, (double) percentage);
     Assert.AreEqual("56.7%", percentage.ToString());
 }
 public void DefaultCtor()
 {
     Percentage percentage = new Percentage();
     Assert.AreEqual(0.0, percentage.Value);
     Assert.AreEqual(0.0, (double) percentage);
     Assert.AreEqual("0%", percentage.ToString());
 }
 //---------------------------------------------------------------------
 private void ValidatePercentage(Percentage percentage)
 {
     if (percentage < 0.0 || percentage > 1.0)
         throw new InputValueException(percentage.ToString(),
                                       "Value must be between 0% and 100%");
 }
 //---------------------------------------------------------------------
 private void Check50Percent(Percentage percentage)
 {
     Assert.AreEqual(0.50, percentage.Value);
     Assert.AreEqual("50%", percentage.ToString());
     Assert.AreEqual("50%", string.Format("{0}", percentage));
     Assert.AreEqual("50%", string.Format("{0:%}", percentage));
     Assert.AreEqual("50.0%", string.Format("{0:#.0%}", percentage));
     Assert.AreEqual(".500", string.Format("{0:#.##0}", percentage));
     Assert.AreEqual(".5", string.Format("{0:#.###}", percentage));
     Assert.AreEqual("0.50", string.Format("{0:0.#0}", percentage));
 }
 public void PercentageMin()
 {
     Percentage percentage = new Percentage(Percentage.MinValueAsDouble);
     Assert.AreEqual(string.Format("{0}%", double.MinValue),
                     percentage.ToString());
 }