protected void Add(IScenarioStep step) { ++scenarioSteps; if (null != currentScenario) { this.currentScenario.Add(() => step.SetUp(), () => step.ExecuteStep(), () => step.CleanUp(), () => step.EndRunCleanUp()); } else { currentScenario = new Scenario(() => step.SetUp(), () => step.ExecuteStep(), () => step.CleanUp(), () => step.EndRunCleanUp()); scenarios.Add(currentScenario); } }
public void OnStepExecuted(IScenarioStep step) { // Step step = GetStep(stepObject); int currIdx = GetStepIndex(step); if (currIdx == currentHighestStepIndex - 1) { Debug.Log(currIdx); Debug.Log("previous step"); } else if (currIdx == currentHighestStepIndex) { if (!downfall) { // steps[currIdx].step.DeactivateStep(); steps[currIdx].onDeactivate.Invoke(); } int idx = currentHighestStepIndex + 1; if (steps.Count > idx) { currentHighestStepIndex = idx; steps[currentHighestStepIndex].step.ActivateStep(); steps[currentHighestStepIndex].onActivate.Invoke(); } else { Debug.Log("scenario ended"); ScenarioEnded.Invoke(); } } else if (currIdx < currentHighestStepIndex) { for (int i = currentHighestStepIndex; i > currIdx; i--) { // steps[i].step.DeactivateStep(); steps[i].onDeactivate.Invoke(); } currentHighestStepIndex = currIdx + 1; steps[currentHighestStepIndex].step.ActivateStep(); //possible bug steps[currentHighestStepIndex].onActivate.Invoke(); } }
/** * Attaching observer to steams * * @param responseObserver * @return */ public override async Task Register(IAsyncStreamReader <ChaincodeMessage> requestStream, IServerStreamWriter <ChaincodeMessage> responseStream, ServerCallContext context) { try { writer = responseStream; while (await requestStream.MoveNext().ConfigureAwait(false)) { ChaincodeMessage chaincodeMessage = requestStream.Current; logger.Information("Mock peer => Got message: " + chaincodeMessage); lastMessageRcvd = chaincodeMessage; if (scenario.Count > 0) { IScenarioStep step = scenario[0]; scenario.RemoveAt(0); if (step.Expected(chaincodeMessage)) { List <ChaincodeMessage> nextSteps = step.Next(); foreach (ChaincodeMessage m in nextSteps) { lastMessageSend = m; logger.Information("Mock peer => Sending response message: " + m); await responseStream.WriteAsync(m).ConfigureAwait(false); } } else { logger.Warning($"Non expected message rcvd in step {step.GetType().Name}"); } lastExecutedStepNumber++; } } } catch (Exception) { //Ignored } }
internal void AddStep(IScenarioStep step) { _steps.Add(step); }
private Step GetStep(IScenarioStep step) { return(steps.SingleOrDefault(x => x.step == step)); }
private int GetStepIndex(IScenarioStep step) { var item = GetStep(step); return(steps.IndexOf(item)); }
public void Add(IScenarioStep scenarioStep) { toExec.Add(new ScenarioItem(() => scenarioStep.CleanUp(), () => scenarioStep.ExecuteStep(), () => scenarioStep.CleanUp(), () => scenarioStep.EndRunCleanUp())); }
public void ASimpleScenario() { subject = Scenario.Given(() => { }); }
public static void Execute(this IScenarioStep currentStep) { ((Scenario.ScenarioRunner)currentStep).Execute(); }
public static IScenarioStep But <T1, T2>(this IScenarioStep currentStep, Action <T1, T2> stepAction, T1 param1, T2 param2) { ((Scenario.ScenarioRunner)currentStep).AddStep(" but", stepAction, param1, param2); return(currentStep); }
public static IScenarioStep But(this IScenarioStep currentStep, Action stepAction) { ((Scenario.ScenarioRunner)currentStep).AddStep(" but", stepAction); return(currentStep); }
public static IScenarioStep And <T>(this IScenarioStep currentStep, Action <T> stepAction, T param1) { ((Scenario.ScenarioRunner)currentStep).AddStep(" and", stepAction, param1); return(currentStep); }