Пример #1
0
        public void Locks_itself_and_notifies_when_failure_rate_exceeds_defined_threshold()
        {
            worker.ThrowException = true;

            Assert.Throws <ApiUnavailableException>(async() => await api.Answer(query));
            Assert.Throws <ApiUnavailableException>(async() => await api.Answer(query));
            Assert.Throws <ApiUnavailableException>(async() => await api.Answer(query));

            IsTrue(() => Observers.Events().Count() == 1);
            IsTrue(() => Observers.FirstEvent <AvailabilityChanged>().Available == false);
            IsTrue(() => Timers.Count() == 1);

            var timer = Timer("check");

            IsTrue(() => timer.Callback == api.CheckAvailability);
            IsTrue(() => timer.Due == TimeSpan.FromSeconds(1));
            IsTrue(() => timer.Period == TimeSpan.FromSeconds(1));
        }