public void Execute(SequenceExecutionContext context) { for (int i = 0; i < _numberOfSends; i++) { _stepToRepeat.Execute(context); } }
public void ExecuteNextStep_ExecutingWhileTriggeringNewSequenceOfEventsAsync_CanHandleAsyncExecuteAndAddNewSequences() { // Arrange var sequence = new TriggeredMessageSequence(); var executionContext = new SequenceExecutionContext(new List<IMessageSequence> {sequence}, "whatever", new Mock<IMessagePicker>().Object); sequence.SetNextStep(new SendMessage(new Mock<ISender>().Object)); // Act IList<Task> tasks = new List<Task>(); for (int i = 0; i < 1000; i++) { var execute = new Task(obj => sequence.ExecuteNextStep(obj as SequenceExecutionContext), executionContext); var triggerNewSequenceOfEvents = new Task(() => sequence.TriggerNewSequenceOfEvents(new Mock<IMessageInitializerParameterBinder>().Object)); tasks.Add(execute); tasks.Add(triggerNewSequenceOfEvents); execute.Start(); triggerNewSequenceOfEvents.Start(); } foreach (var task in tasks) { task.Wait(); } // Assert Assert.That(tasks.All(task => task.IsCompleted)); }
public void ExecuteNextStep_ExecutingWhileTriggeringNewSequenceOfEventsAsync_CanHandleAsyncExecuteAndAddNewSequences() { // Arrange var sequence = new TriggeredMessageSequence(); var executionContext = new SequenceExecutionContext(new List <IMessageSequence> { sequence }, "whatever", new Mock <IMessagePicker>().Object); sequence.SetNextStep(new SendMessage(new Mock <ISender>().Object)); // Act IList <Task> tasks = new List <Task>(); for (int i = 0; i < 1000; i++) { var execute = new Task(obj => sequence.ExecuteNextStep(obj as SequenceExecutionContext), executionContext); var triggerNewSequenceOfEvents = new Task(() => sequence.TriggerNewSequenceOfEvents(new Mock <IMessageInitializerParameterBinder>().Object)); tasks.Add(execute); tasks.Add(triggerNewSequenceOfEvents); execute.Start(); triggerNewSequenceOfEvents.Start(); } foreach (var task in tasks) { task.Wait(); } // Assert Assert.That(tasks.All(task => task.IsCompleted)); }
public void Execute(SequenceExecutionContext context) { bool expectationHasBeenMet = false; while (!expectationHasBeenMet) { expectationHasBeenMet = TestExpectationIfAnyMessageOnQueue(context); } }
public bool TestExpectationIfAnyMessageOnQueue(SequenceExecutionContext context) { object[] nextMessage = context.GetNextMessage(_owningSequence); if (nextMessage == null) return false; return _expectation.Met(nextMessage); }
public bool TestExpectationIfAnyMessageOnQueue(SequenceExecutionContext context) { object[] nextMessage = context.GetNextMessage(_owningSequence); if (nextMessage == null) { return(false); } return(_expectation.Met(nextMessage)); }
public void ExecuteNextStep(SequenceExecutionContext executionContext) { if (Done) return; if (UpdateExecutionContextWithNextStep(executionContext)) { IStep currentStep = executionContext.GetCurrentStep(this); currentStep.Execute(executionContext); } }
public void ExecuteNextStep(SequenceExecutionContext executionContext) { if (Done) { return; } if (UpdateExecutionContextWithNextStep(executionContext)) { IStep currentStep = executionContext.GetCurrentStep(this); currentStep.Execute(executionContext); } }
private bool UpdateExecutionContextWithNextStep(SequenceExecutionContext executionContext) { if (executionContext.GetCurrentStep(this) == null) executionContext.SetCurrentStep(this, _chain.Root); else { IStep current = executionContext.GetCurrentStep(this); IStep next = _chain.GetStepAfter(current); if (next == null) { executionContext.Cleanup(this); Done = true; } else executionContext.SetCurrentStep(this, next); } return !Done; }
private bool UpdateExecutionContextWithNextStep(SequenceExecutionContext executionContext) { if (executionContext.GetCurrentStep(this) == null) { executionContext.SetCurrentStep(this, _chain.Root); } else { IStep current = executionContext.GetCurrentStep(this); IStep next = _chain.GetStepAfter(current); if (next == null) { executionContext.Cleanup(this); Done = true; } else { executionContext.SetCurrentStep(this, next); } } return(!Done); }
public void Execute(SequenceExecutionContext context) { _sender.Send(); }
public void Execute(SequenceExecutionContext context) { for(int i = 0; i < _numberOfSends; i++) _stepToRepeat.Execute(context); }