Beispiel #1
0
        void IMockPlug.Verify(TimeSpan timeout, Times times)
        {
            while(true) {
                var verified = times.Verify(_times, timeout);
                if(verified == Times.Result.Ok) {
                    _log.DebugFormat("satisfied {0}", _uri);
                    return;
                }
                if(verified == Times.Result.TooMany) {
                    break;
                }

                // check if we have any time left to wait
                if(timeout.TotalMilliseconds < 0) {
                    break;
                }
                _log.DebugFormat("waiting on {0}:{1} with {2:0.00}ms left in timeout", _verb, _uri, timeout.TotalMilliseconds);
                var stopwatch = Stopwatch.StartNew();
                if(!_called.WaitOne(timeout)) {
                    break;
                }
                timeout = timeout.Subtract(stopwatch.Elapsed);
            }
            throw new MockPlugException(string.Format("[{0}] {1}:{2} was called {3} times before timeout.", Name, _verb, _uri, _times));
        }
Beispiel #2
0
 IMockPlug IMockPlug.ExpectCalls(Times called)
 {
     _verifiable = called;
     return this;
 }
Beispiel #3
0
 void IMockPlug.Verify(Times times)
 {
     ((IMockPlug)this).Verify(TimeSpan.FromSeconds(5), times);
 }
Beispiel #4
0
 IMockPlug IMockPlug.ExpectAtLeastOneCall()
 {
     _verifiable = Times.AtLeastOnce();
     return this;
 }