public void ProgressViewModel_SetUpperBoundLimitedValue() { // Arrange ProgressViewModel testSubject = new ProgressViewModel(); // Sanity testSubject.Value.Should().Be(0, "Default value expected"); // Act + Assert // 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 testSubject.Value.Should().Be(0.0, "Erroneous cases should not change the default value"); // NaN supported testSubject.SetUpperBoundLimitedValue(double.NaN); testSubject.Value.Should().Be(double.NaN); // Zero in range testSubject.SetUpperBoundLimitedValue(0); testSubject.Value.Should().Be(0.0); // One is in range testSubject.SetUpperBoundLimitedValue(1); testSubject.Value.Should().Be(1.0); // Anything between zero and one is in range Random r = new Random(); double val = r.NextDouble(); testSubject.SetUpperBoundLimitedValue(val); testSubject.Value.Should().Be(val); // More than one (i.e floating point summation errors) will become one testSubject.SetUpperBoundLimitedValue(1.0 + ProgressViewModel.UpperBoundMarginalErrorSupport); testSubject.Value.Should().Be(1.0); }