public static void RegisterRepeatCount(this ScenarioStepContext context, string repeatContextName, int count) { if (!ExecutionContextContainer.Contexts[Thread.CurrentThread.ManagedThreadId].RegressionEnabled) { throw new TagNotSetException("enable-regression", nameof(RegisterRepeatCount)); } var contextDictionary = ExecutionContextContainer.Contexts[Thread.CurrentThread.ManagedThreadId].RepeatContext; contextDictionary[repeatContextName] = new RepeatContext() { Count = count, BeginStepDefinition = context.CurrentStep() }; }
public static void DecrementRepeatCount(this ScenarioStepContext context, string repeatContextName) { if (!ExecutionContextContainer.Contexts[Thread.CurrentThread.ManagedThreadId].RegressionEnabled) { throw new TagNotSetException("enable-regression", nameof(DecrementRepeatCount)); } var contextDictionary = ExecutionContextContainer.Contexts[Thread.CurrentThread.ManagedThreadId].RepeatContext; if (contextDictionary.ContainsKey(repeatContextName)) { contextDictionary[repeatContextName] = new RepeatContext() { Count = contextDictionary[repeatContextName].Count - 1, BeginStepDefinition = contextDictionary[repeatContextName].BeginStepDefinition, EndStepDefinition = context.CurrentStep() }; } else { throw new AdvanceStepsException($"Repeat context with the name {repeatContextName} is not yet set, please call 'RegisterRepeatCount' to set it"); } }