public async void Continue_executing_scheduled_searches_if_retry_succeeds() { // arrange await TopicCreated(); RetriesScheduled("facebook"); // see that timer was registered IsTrue(() => Timers.Count() == 1); // return something facebook .ExpectQuery <Search>() .Return(122); // act await topic.RetrySearch("facebook"); // see that timer was registered IsFalse(() => Timers.Any(), "Should unregister retry timer"); /* now, check regular searching works as expected #1# */ // arrange facebook.Reset(); // act await ReceiveReminder("facebook"); // assert sent search query IsTrue(() => facebook.Queries().Count() == 1); IsTrue(() => facebook.FirstQuery <Search>().Subject == subject); }
public void Validate(ValidationResult result) { if (Timers == null) { Timers = new List <Timer>(); } if (Inputs.Select(param => param.Key).Distinct().Count() != Inputs.Count()) { result.AddUserError("Duplicate Keys found on Inputs."); } if (Attributes.Select(param => param.Key).Distinct().Count() != Attributes.Count()) { result.AddUserError("Duplicate Keys found on Attributes."); } if (InputCommands.Select(param => param.Key).Distinct().Count() != InputCommands.Count()) { result.AddUserError("Duplicate Keys found on Input Commands."); } if (StateMachines.Select(param => param.Key).Distinct().Count() != StateMachines.Count()) { result.AddUserError("Duplicate Keys found on State Machines."); } if (OutputCommands.Select(param => param.Key).Distinct().Count() != OutputCommands.Count()) { result.AddUserError("Duplicate Keys found on Output Commands."); } if (Timers.Select(param => param.Key).Distinct().Count() != Timers.Count()) { result.AddUserError("Duplicate Keys found on Timers."); } foreach (var input in Inputs) { input.Validate(this, result); } foreach (var attribute in Attributes) { attribute.Validate(this, result); } foreach (var inputCommand in InputCommands) { inputCommand.Validate(this, result); } foreach (var stateMachine in StateMachines) { stateMachine.Validate(this, result); } foreach (var outputCommand in OutputCommands) { outputCommand.Validate(this, result); } foreach (var timer in Timers) { timer.Validate(this, result); } }
public async void Locks_itself_and_notifies_when_failure_rate_exceeds_defined_threshold() { await api.Answer(new Search("ПТН ПНХ")); IsTrue(() => api.IsAvailable == false); IsTrue(() => notifications.Count == 1); IsTrue(() => notifications[0].Available == false); IsTrue(() => Timers.Count() == 1); var timer = CallbackTimer("check"); IsTrue(() => timer.Callback == api.CheckAvailability); IsTrue(() => timer.Due == TimeSpan.FromSeconds(1)); IsTrue(() => TimeSpan.FromSeconds(1) <= timer.Period && timer.Period <= TimeSpan.FromSeconds(3)); }
public void Locks_itself_and_notifies_when_failure_rate_exceeds_defined_threshold() { worker.ThrowException = true; Assert.ThrowsAsync <ApiUnavailableException>(async() => await api.Handle(query)); Assert.ThrowsAsync <ApiUnavailableException>(async() => await api.Handle(query)); Assert.ThrowsAsync <ApiUnavailableException>(async() => await api.Handle(query)); IsTrue(() => observers.Events().Count() == 1); IsTrue(() => observers.FirstEvent <AvailabilityChanged>().Available == false); IsTrue(() => Timers.Count() == 1); var timer = Timer("check"); IsTrue(() => timer.CallbackTimer().Callback == api.CheckAvailability); IsTrue(() => timer.Due == TimeSpan.FromSeconds(1)); IsTrue(() => timer.Period == TimeSpan.FromSeconds(1)); }