public void ToString_should_return_the_correct_string(int milliseconds, string expectedString)
        {
            var result = TimeSpanParser.ToString(TimeSpan.FromMilliseconds(milliseconds));

            result.Should().Be(expectedString);
        }
Esempio n. 2
0
 /// <summary>
 /// Ensures that the value of a parameter is greater than or equal to zero.
 /// </summary>
 /// <param name="value">The value of the parameter.</param>
 /// <param name="paramName">The name of the parameter.</param>
 /// <returns>The value of the parameter.</returns>
 public static TimeSpan IsGreaterThanOrEqualToZero(TimeSpan value, string paramName)
 {
     if (value < TimeSpan.Zero)
     {
         var message = string.Format("Value is not greater than or equal to zero: {0}.", TimeSpanParser.ToString(value));
         throw new ArgumentOutOfRangeException(paramName, message);
     }
     return(value);
 }
Esempio n. 3
0
 /// <summary>
 /// Ensures that the value of a parameter is null, or infinite, or greater than or equal to zero.
 /// </summary>
 /// <param name="value">The value of the parameter.</param>
 /// <param name="paramName">The name of the parameter.</param>
 /// <returns>The value of the parameter.</returns>
 public static TimeSpan?IsNullOrInfiniteOrGreaterThanOrEqualToZero(TimeSpan?value, string paramName)
 {
     if (value.HasValue && value.Value < TimeSpan.Zero && value.Value != Timeout.InfiniteTimeSpan)
     {
         var message = string.Format("Value is not null or infinite or greater than or equal to zero: {0}.", TimeSpanParser.ToString(value.Value));
         throw new ArgumentOutOfRangeException(paramName, message);
     }
     return(value);
 }
Esempio n. 4
0
        /// <summary>
        /// Ensures that the value of a parameter is infinite or greater than zero.
        /// </summary>
        /// <param name="value">The value of the parameter.</param>
        /// <param name="paramName">The name of the parameter.</param>
        /// <returns>The value of the parameter.</returns>
        public static TimeSpan IsInfiniteOrGreaterThanZero(TimeSpan value, string paramName)
        {
            if (value == Timeout.InfiniteTimeSpan || value > TimeSpan.Zero)
            {
                return(value);
            }
            var message = string.Format("Value is not infinite or greater than zero: {0}.", TimeSpanParser.ToString(value));

            throw new ArgumentOutOfRangeException(paramName, message);
        }