public SetUpperBoundLimitedValue ( double value ) : void | ||
value | double | |
return | void |
public void ProgressViewModel_SetUpperBoundLimitedValue() { // Setup ProgressViewModel testSubject = new ProgressViewModel(); // Sanity Assert.AreEqual(0, testSubject.Value, "Default value expected"); // Act + Verify // Erroneous cases Exceptions.Expect<ArgumentOutOfRangeException>(() => testSubject.SetUpperBoundLimitedValue(double.NegativeInfinity)); Exceptions.Expect<ArgumentOutOfRangeException>(() => testSubject.SetUpperBoundLimitedValue(double.PositiveInfinity)); Exceptions.Expect<ArgumentOutOfRangeException>(() => testSubject.SetUpperBoundLimitedValue(0 - double.Epsilon)); Exceptions.Expect<ArgumentOutOfRangeException>(() => testSubject.SetUpperBoundLimitedValue(1.0 + ProgressViewModel.UpperBoundMarginalErrorSupport + ProgressViewModel.UpperBoundMarginalErrorSupport)); // Sanity Assert.AreEqual(0.0, testSubject.Value, "Erroneous cases should not change the default value"); // NaN supported testSubject.SetUpperBoundLimitedValue(double.NaN); Assert.AreEqual(double.NaN, testSubject.Value); // Zero in range testSubject.SetUpperBoundLimitedValue(0); Assert.AreEqual(0.0, testSubject.Value); // One is in range testSubject.SetUpperBoundLimitedValue(1); Assert.AreEqual(1.0, testSubject.Value); // Anything between zero and one is in range Random r = new Random(); double val = r.NextDouble(); testSubject.SetUpperBoundLimitedValue(val); Assert.AreEqual(val, testSubject.Value); // More than one (i.e floating point summation errors) will become one testSubject.SetUpperBoundLimitedValue(1.0 + ProgressViewModel.UpperBoundMarginalErrorSupport); Assert.AreEqual(1.0, testSubject.Value); }