Exemplo n.º 1
0
        public void ConvertToMillisecondsThrowsWhenNumberOfMillisecondsIsSuperiorToTheIntMaxValue()
        {
            double maxValue = int.MaxValue;

            maxValue++;
            Duration.ConvertToMilliseconds(maxValue, TimeUnit.Milliseconds);
        }
Exemplo n.º 2
0
 public void ConvertToMillisecondsThrowsWhenNumberOfMillisecondsIsSuperiorToTheIntMaxValue()
 {
     Check.ThatCode(() =>
     {
         double maxValue = int.MaxValue;
         maxValue++;
         Duration.ConvertToMilliseconds(maxValue, TimeUnit.Milliseconds);
     })
     .Throws <OverflowException>();
 }
        /// <summary>
        /// Checks that the event is not set within a given timeout.
        /// </summary>
        /// <param name="check">The fluent check to be extended.</param>
        /// <param name="timeOut">The maximum amount of time before the event should not be set (time unit being specified with the timeUnit parameter).</param>
        /// <param name="timeUnit">The time unit of the given timeOut.</param>
        /// <returns>
        /// A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">The event was set before the given timeout.</exception>
        public static ICheckLink <ICheck <EventWaitHandle> > IsNotSetWithin(this ICheck <EventWaitHandle> check, double timeOut, TimeUnit timeUnit)
        {
            var checker       = ExtensibilityHelper.ExtractChecker(check);
            var timeOutInMsec = Duration.ConvertToMilliseconds(timeOut, timeUnit);

            return(checker.ExecuteCheck(
                       () =>
            {
                if (checker.Value.WaitOne(timeOutInMsec))
                {
                    var errorMessage = checker.BuildShortMessage(string.Format("The checked event has been set before the given timeout.\nThe given timeout (in msec):\n\t[{0}]", timeOutInMsec)).ToString();
                    throw new FluentCheckException(errorMessage);
                }
            },
                       checker.BuildShortMessage(string.Format("The checked event has not been set before the given timeout whereas it must.\nThe given timeout (in msec):\n\t[{0}]", timeOutInMsec)).ToString()));
        }
Exemplo n.º 4
0
        public void ConvertToMillisecondsWorksWith2Days()
        {
            int durationInMsec = Duration.ConvertToMilliseconds(2, TimeUnit.Days);

            Check.That(durationInMsec).IsEqualTo(2 * 24 * 60 * 60 * 1000);
        }
Exemplo n.º 5
0
        public void ConvertToMillisecondsWorksWith2Seconds()
        {
            int durationInMsec = Duration.ConvertToMilliseconds(2, TimeUnit.Seconds);

            Check.That(durationInMsec).IsEqualTo(2000);
        }