private List <string> GenerateRCommnad(StepDefinition stepDef, int stepNo) { List <string> scripts = new List <string>(); int smpCnt = GlobalVars.Instance.SampleCount; // Source labware: Trough 100ml, labeled 'T2', use wells 1 - 8 // Destination labware: 96 Well Microplate, labeled 'MTP96-2', use wells 1 - 96 // Liquid class 'Water' // DiTi Reuse = 2 (use 2 times), Multi-dispense = max. 5 // Pipetting direction 0 = left to right // No wells to be excluded // R;T2;;Trough 100ml;1;8;MTP96-2;;96 Well Microplate;1;96;100;Water;2;5;0 string liquidClass = stepDef.LiquidClass; string adaptiveWell = string.Format("1;{0}", GlobalVars.Instance.SampleCount); string aspWellsUse = IsFixedPostion(stepDef.AspirateConstrain) ? stepDef.AspirateConstrain.Replace('-', ';') : adaptiveWell; string dispenseWellsUse = IsFixedPostion(stepDef.DispenseConstrain) ? stepDef.DispenseConstrain.Replace('-', ';') : adaptiveWell; scripts.Add(string.Format("C;{0}", stepDef.Description)); string reagentCommand = string.Format("R;{0};;;{1};{2};;;{3};{4};{5};{6};5;0", stepDef.SourceLabware, aspWellsUse, stepDef.DestLabware, dispenseWellsUse, stepDef.Volume, stepDef.LiquidClass, stepDef.ReuseTimes); scripts.Add(reagentCommand); return(scripts); }
private void CreateSampleStep(StepDefinition stepDefinition) { BindingInfo bindingInfo = bindingByStepDef[stepDefinition]; Debug.Assert(bindingInfo != null); switch (stepDefinition.Type) { case "Given": stepDefinition.ScenarioStep = new Given(); break; case "When": stepDefinition.ScenarioStep = new When(); break; case "Then": stepDefinition.ScenarioStep = new Then(); break; default: throw new InvalidOperationException(); } stepDefinition.ScenarioStep.Text = GetSampleText(bindingInfo); }
public void GivenTheFollowingCStepDefinitionClassInTheEditor(string stepDefinitionClass) { var fileName = "Steps.cs"; var stepDefinitionFile = string.Join(Environment.NewLine, new[] { "using System;", "using TechTalk.SpecFlow;", "", "namespace MyProject", "{", stepDefinitionClass, "}" }); var namespaceValue = Regex.Match(stepDefinitionFile, @"namespace (?<value>\S+)").Groups["value"].Value; var classValue = Regex.Match(stepDefinitionFile, @"public class (?<value>\S+)").Groups["value"].Value; var methodValue = Regex.Match(stepDefinitionFile, @"public void (?<value>[^\(\s]+)").Groups["value"].Value; var stepDefTypeValue = Regex.Match(stepDefinitionFile, @"\[(?<value>Given|When|Then)\(").Groups["value"].Value; var regexValue = Regex.Match(stepDefinitionFile, @"\[(?:Given|When|Then)\(\@?""(?<value>.*?)""\)\]").Groups["value"].Value; var locationMatch = Regex.Match(stepDefinitionFile, @"^(?<line>.*\r\n)*\s*\[(?:Given|When|Then)"); var stepDefinition = new StepDefinition() { Regex = regexValue, Method = $"{namespaceValue}.{classValue}.{methodValue}", ParamTypes = "", Type = stepDefTypeValue, SourceLocation = $"{fileName}|{locationMatch.Groups["line"].Captures.Count + 3}|1" }; _ideScope.Logger.LogInfo(stepDefinition.SourceLocation); RegisterStepDefinitions(stepDefinition); WhenTheProjectIsBuilt(); _wpfTextView = StubWpfTextView.CreateTextView(_ideScope, new TestText(stepDefinitionFile), projectScope: _projectScope, contentType: "text", filePath: fileName); }
/// <summary> /// Unfreeze the process /// </summary> /// <param name="processRuntimeId"></param> /// <param name="runtime"></param> /// <param name="nextStep"></param> /// <param name="collection"></param> /// <returns></returns> public override bool TryUnfreeze(Guid processRuntimeId, out IProcessRuntime runtime, out StepRuntime nextStep, out IPropertySetCollection collection) { runtime = null; collection = null; nextStep = null; using (var ctx = new ProcessDbContext()) { var rtp = ctx.Process.Find(processRuntimeId); if (rtp == null) { return(false); } var definition = JsonConvert.DeserializeObject <ProcessDefinition>(rtp.ProcessDefinition.JsonProcessDefinition); definition.Id = rtp.ProcessDefinition.Id; collection = rtp.PropertyCollection.Deserialize(); if (!string.IsNullOrEmpty(rtp.NextStepId)) { StepDefinition stepDef = definition.Steps.Single(s => s.StepId == rtp.NextStepId); StepDefinitionId sid = new StepDefinitionId(stepDef.Id, stepDef.StepId); LinkDefinition[] links = definition.Links.Where(l => l.Source == sid).ToArray(); nextStep = new StepRuntime(stepDef, links.Select(l => new LinkRuntime(l)).ToArray()); } runtime = Create(rtp.Id, definition, rtp.SuspendedStepId, (ProcessStateEnum)rtp.Status); } return(true); }
public void SetUp() { _successMethod = Reflection.GetMethod(typeof(ValidStepDefinitions), "Succeeds"); _exceptionMethod = Reflection.GetMethod(typeof(ValidStepDefinitions), "ThrowsException"); _stepDefinition = new StepDefinition(_successMethod); }
private List <LihaCommand> GetLihaCommandsThisBatch(List <int> sourceWellIDs, List <int> dstWellIDs, StepDefinition stepDef) { List <string> strs = new List <string>(); double tipType = 1000;//int.Parse(stepDef.TipType); double maxVolumePerTip = tipType * 0.9; double volumeThisStep = stepDef.Volume; int nTotalTimes = (int)Math.Ceiling(volumeThisStep / maxVolumePerTip); double finishedVolume = 0; List <LihaCommand> lihaCommands = new List <LihaCommand>(); for (int i = 0; i < nTotalTimes; i++) { double remainingVolume = volumeThisStep - finishedVolume; double volumeThisTime = Math.Min(remainingVolume, maxVolumePerTip); if (remainingVolume > maxVolumePerTip && remainingVolume - maxVolumePerTip <= tipType * 0.2) { volumeThisTime = (int)(remainingVolume / 2.0); } finishedVolume += volumeThisTime; for (int j = 0; j < sourceWellIDs.Count; j++) { string sBarcode = GlobalVars.Instance.Tube_Barcode[j + 1]; lihaCommands.Add(new LihaCommand(sBarcode, stepDef.SourceLabware, sourceWellIDs[j], volumeThisTime, stepDef.DestLabware, dstWellIDs[j], stepDef.DitiType, "water")); } } return(lihaCommands); }
public void SetUp() { _stepDefinition = new StepDefinition(Reflection.GetMethod(GetType(), "CheckMethodCalled")); _exceptionDefinition = new StepDefinition(Reflection.GetMethod(GetType(), "ThrowsException")); _stepDefinitionWithOneStringParameter = new StepDefinition(GetType().GetMethod("OneStringParameter")); _stepDefinitionWithMultipleStringParameters = new StepDefinition(GetType().GetMethod("MultipleStringParameters", new Type[] { typeof(string), typeof(string) })); _stepDefinitionWithMultipleStringParametersOverloaded = new StepDefinition(GetType().GetMethod("MultipleStringParameters", new Type[] { typeof(string), typeof(string), typeof(string) })); _stepDefinitionWithOneIntParameter = new StepDefinition(GetType().GetMethod("OneIntParameter")); _stepDefinitionWithOneDoubleParameter = new StepDefinition(GetType().GetMethod("OneDoubleParameter")); _stepDefinitionWithIntDoubleAndStringParameters = new StepDefinition(GetType().GetMethod("IntDoubleAndStringParameters")); _pendingStepDefinition = new StepDefinition(GetType().GetMethod("Pending")); _stepDefinitionWithTableDiff = new StepDefinition(GetType().GetMethod("TableDiff")); _stepDefinitions = new List <StepDefinition> { _stepDefinition, _exceptionDefinition, _stepDefinitionWithOneStringParameter, _stepDefinitionWithMultipleStringParameters, _stepDefinitionWithMultipleStringParametersOverloaded, _stepDefinitionWithOneIntParameter, _stepDefinitionWithOneDoubleParameter, _stepDefinitionWithIntDoubleAndStringParameters, _pendingStepDefinition, _stepDefinitionWithTableDiff }; var loader = new MockLoader(_stepDefinitions); var objectFactory = new ObjectFactory(); _processor = new Processor(loader, objectFactory); _methodCalled = false; _receivedParameters = null; }
public ReportElements.StepDefinitionReport GenerateReport() { report = new ReportElements.StepDefinitionReport(); report.ProjectName = specFlowProject.ProjectSettings.ProjectName; report.GeneratedAt = DateTime.Now.ToString("g", CultureInfo.InvariantCulture); report.ShowBindingsWithoutInsance = ReportParameters.ShowBindingsWithoutInsance; stepDefByBinding = new Dictionary<BindingInfo, StepDefinition>(); bindingByStepDef = new Dictionary<StepDefinition, BindingInfo>(); foreach (var bindingInfo in bindings) { var stepDefinition = new StepDefinition(); stepDefinition.Binding = new Binding { MethodReference = bindingInfo.MethodReference }; stepDefinition.Type = bindingInfo.BindingType; stepDefByBinding.Add(bindingInfo, stepDefinition); bindingByStepDef.Add(stepDefinition, bindingInfo); report.StepDefinitions.Add(stepDefinition); } foreach (var feature in parsedFeatures) { var featureRef = new FeatureRef { FilePath = feature.SourceFile, Name = feature.Title }; if (feature.Background != null) { var scenarioRef = new ScenarioRef { Name = "Background" }; AddStepInstances(featureRef, scenarioRef, feature.Background.Steps, false); } foreach (var scenario in feature.Scenarios) { var scenarioRef = new ScenarioRef { Name = scenario.Title, SourceFileLine = scenario.FilePosition == null ? -1 : scenario.FilePosition.Line }; if (scenario is ScenarioOutline) { ScenarioSteps firstExampleSteps = CreateFirstExampleScenarioSteps((ScenarioOutline) scenario); AddStepInstances(featureRef, scenarioRef, firstExampleSteps, true); } else { AddStepInstances(featureRef, scenarioRef, scenario.Steps, false); } } } foreach (var stepDefinition in report.StepDefinitions) { if (stepDefinition.ScenarioStep == null) { CreateSampleStep(stepDefinition); } if (stepDefinition.Instances.Count == 0) { stepDefinition.Instances = null; } } return report; }
/// <summary> /// Create a new LogDownloader /// </summary> /// <param name="isAsyncTransfer">Determines if this machine will be set up asyncronus transfers.</param> /// <param name="threadName">The name to report in closing operations for this binary socket.</param> /// <param name="closingWorker">The closing worker to add this binary socket too.</param> protected ThreadedTransferMachine(bool isAsyncTransfer, string threadName, ClosingWorker closingWorker) : base(threadName) { // add thread to the closing worker closingWorker?.AddThread(this); // initialize the StateMachine WorkerState = new StateDefinition(); if (isAsyncTransfer) { MachineFunctions.InitializeStates(WorkerStateMachine = new StepDefinition(threadName, true, WorkerState) { #region StateMachine SubSteps = new List <StepDefinition> { new StepDefinition("Transfer Packet") { Delegate = StateMachine_TransferPacket, DelayTimeMs = 500 }, new StepDefinition("Packet Timeout") { Delegate = StateMachine_PacketTimeout, DelayTimeMs = 0 }, new StepDefinition("Complete") { Delegate = StateMachine_Complete, DelayTimeMs = 200 } } #endregion // StateMachine }); } else { MachineFunctions.InitializeStates(WorkerStateMachine = new StepDefinition(threadName, true, WorkerState) { #region StateMachine SubSteps = new List <StepDefinition> { new StepDefinition("Transfer Packet") { Delegate = StateMachine_TransferPacket, DelayTimeMs = 0 }, new StepDefinition("Complete") { Delegate = StateMachine_Complete, DelayTimeMs = 200 } } #endregion // StateMachine }); } // start the StateMachine in the Complete state MachineFunctions.JumpToLast(WorkerStateMachine); // initialize ThreadingBase WorkerThreads = new List <ThreadInfo> { new ThreadInfo(new Thread(Worker), "State Machine", threadName, WorkerStateMachine) }; }
private void CreateSampleStep(StepDefinition stepDefinition) { BindingInfo bindingInfo = bindingByStepDef[stepDefinition]; Debug.Assert(bindingInfo != null); var sampleText = GetSampleText(bindingInfo); switch (stepDefinition.Type) { case "Given": stepDefinition.ScenarioStep = new ReportStep(SpecFlowLocation.Empty, "Given", sampleText, null, StepKeyword.Given, Parser.ScenarioBlock.Given); break; case "When": stepDefinition.ScenarioStep = new ReportStep(SpecFlowLocation.Empty, "When", sampleText, null, StepKeyword.When, Parser.ScenarioBlock.When); break; case "Then": stepDefinition.ScenarioStep = new ReportStep(SpecFlowLocation.Empty, "Then", sampleText, null, StepKeyword.Then, Parser.ScenarioBlock.Then); break; case "StepDefinition": stepDefinition.ScenarioStep = new ReportStep(SpecFlowLocation.Empty, "StepDefinition", sampleText, null, null, null); break; default: throw new InvalidOperationException(); } }
public ProjectStepDefinitionBinding ImportStepDefinition(StepDefinition stepDefinition) { try { var stepDefinitionType = (ScenarioBlock)Enum.Parse(typeof(ScenarioBlock), stepDefinition.Type); var regex = new Regex(stepDefinition.Regex, RegexOptions.CultureInvariant); var sourceLocation = ParseSourceLocation(stepDefinition.SourceLocation); var scope = ParseScope(stepDefinition.Scope); var parameterTypes = ParseParameterTypes(stepDefinition.ParamTypes); if (!_implementations.TryGetValue(stepDefinition.Method, out var implementation)) { implementation = new ProjectStepDefinitionImplementation(stepDefinition.Method, parameterTypes, sourceLocation); _implementations.Add(stepDefinition.Method, implementation); } return(new ProjectStepDefinitionBinding(stepDefinitionType, regex, scope, implementation)); } catch (Exception ex) { _logger.LogWarning($"Invalid binding: {ex.Message}"); return(null); } }
public void ShouldTakePatternAndMethodInConstructor() { MethodInfo dummyMethod = this.GetType().GetMethod("DummyMethod"); StepDefinition sd = new StepDefinition(".*", dummyMethod); Assert.That(sd.Pattern, Is.EqualTo(".*")); Assert.That(sd.Method, Is.EqualTo(dummyMethod)); }
private List <PipettingInfo> GetPipettingInfosBatch(List <int> sourceWellIDs, List <int> dstWellIDs, StepDefinition stepDef, string assayName = "") { List <string> strs = new List <string>(); double tipType = int.Parse(stepDef.TipType); double maxVolumePerTip = tipType * 0.9; double volumeThisStep = double.Parse(stepDef.Volume); int nTotalTimes = (int)Math.Ceiling(volumeThisStep / maxVolumePerTip); double finishedVolume = 0; string srcLabware = assayName == string.Empty ? stepDef.SourceLabware : assayName + stepDef.SourceLabware.Last(); List <PipettingInfo> pipettingInfos = new List <PipettingInfo>(); for (int i = 0; i < nTotalTimes; i++) { double remainingVolume = volumeThisStep - finishedVolume; double volumeThisTime = Math.Min(remainingVolume, maxVolumePerTip); if (remainingVolume > maxVolumePerTip && remainingVolume - maxVolumePerTip <= tipType * 0.2) { volumeThisTime = (int)(remainingVolume / 2.0); } finishedVolume += volumeThisTime; for (int j = 0; j < sourceWellIDs.Count; j++) { pipettingInfos.Add(new PipettingInfo(srcLabware, sourceWellIDs[j], volumeThisTime, stepDef.DestLabware, dstWellIDs[j])); } } return(pipettingInfos); }
public StepDescription Describe(StepDefinition stepDefinition) { var matcherType = stepDefinition.Matcher.GetType(); return(_describers.ContainsKey(matcherType) ? _describers[matcherType].Describe(stepDefinition) : new StepDescription()); }
private string GetTipType(StepDefinition stepDef) { if (stepDef.Volume == "") { return("C;0"); } return(string.Format("C;{0}", stepDef.TipType)); }
/// <summary> /// Defines a step in the current scenario. /// </summary> /// <param name="text">The step text.</param> /// <param name="body">The action that will perform the step.</param> /// <returns> /// An instance of <see cref="IStepBuilder"/>. /// </returns> public static IStepBuilder x(this string text, Func <IStepContext, Task> body) { var stepDef = new StepDefinition { Text = text, Body = body }; CurrentThread.Add(stepDef); return(stepDef); }
public void it_does_not_remove_punctuation_from_inside_quoted_strings() { var def = new StepDefinition(this, this.GetType().GetMethod("given_the_string_arg1")); def.TryExecute(new Step { Type = StepType.Given, Text = "given the string \"a/b.c!\"" }); this.theString.Should().Be("a/b.c!"); }
public void it_is_not_case_sensitive() { var def = new StepDefinition(this, this.GetType().GetMethod("given_a_foo")); bool matches = def.Matches(new Step { Type = StepType.Given, Text = "GIVEN A FOO" }); matches.Should().Be.True(); }
private List <LihaCommand> GenerateLihaCommandsThisStep(StepDefinition stepDef, int stepNo) { if (stepDef.Volume == 0) { return(new List <LihaCommand>()); } List <LihaCommand> pipettingInfos = GetPipettingInfos(stepDef); return(pipettingInfos); }
public void it_matches_steps_with_punctuation() { var def = new StepDefinition(this, this.GetType().GetMethod("given_a_foo")); bool matches = def.Matches(new Step { Type = StepType.Given, Text = "give'n a: foo!" }); matches.Should().Be.True(); }
public void Successful_invocation_of_instance_should_not_throw() { var objectFactory = new ObjectFactory(); objectFactory.AddClass(typeof(ValidStepDefinitions)); objectFactory.CreateObjects(); var stepDefinition = new StepDefinition(GetValidMethod("Instance")); stepDefinition.Invoke(objectFactory); }
void AssertAllMethodsLoaded(Type type) { var expectedMethods = StepDefinition_Specification.GetStepDefinitionMethods(type); foreach (var method in expectedMethods) { var stepDefinition = new StepDefinition(method); Assert.That(_stepDefinitions, Has.Member(stepDefinition), "Missing method: " + stepDefinition.Id); } }
protected override bool StateMachine_TransferPacket(StepDefinition currentStep) { // check for connection if (!_comPortRef.IsConnected) { SetTransferState(TransferState.FailedConnection); MachineFunctions.JumpToLast(currentStep); return(StepReturn.JumpCommandUsed); } // update the users with % complete RunPercentUpdate(); var returnStrings = _comPortRef.SendCommand($"&@i{_currentPage}", 5000); // check for response if (returnStrings.Count > 0 && returnStrings[0].Contains($"&@i{_currentPage},")) { if (returnStrings[0].Contains($"&@i{_currentPage},MULTILINECOMPLETE")) { // ini downloaded SetTransferState(TransferState.Succeeded); // end the downloader MachineFunctions.JumpToLast(currentStep); return(StepReturn.JumpCommandUsed); } // we have data returnStrings[0] = returnStrings[0].Replace($"&@i{_currentPage},", ""); returnStrings.RemoveRange(returnStrings.Count - 2, 2); _fileText += string.Join("\r\n", returnStrings.ToArray()); _currentPage++; return(StepReturn.RepeatStep); } // deal with any errors switch (returnStrings[0]) { case "&@i!o": SetTransferState(_currentTransferState, "Buffer overflow!"); break; case "&@i!v": SetTransferState(_currentTransferState, "Invalid Page Number!"); break; default: break; } // we had a bad log, try again return(ProcessMissedPage(_currentPage)); }
/// <summary> /// Defines a step in the current scenario. /// </summary> /// <param name="text">The step text.</param> /// <param name="body">The action that will perform the step.</param> /// <returns> /// An instance of <see cref="IStepBuilder"/>. /// </returns> public static IStepBuilder x(this string text, Func <Task> body) { var stepDefinition = new StepDefinition { Text = text, Body = body == null ? default(Func <IStepContext, Task>) : c => body(), }; CurrentThread.StepDefinitions.Add(stepDefinition); return(stepDefinition); }
public void Id_property_should_be_fully_qualified_method_name_with_parameter_types() { var fullNameForParameterlessMethod = typeof(ValidStepDefinitions).FullName + "." + _stepDefinition.Method.Name + "()"; Assert.That(_stepDefinition.Id, Is.EqualTo(fullNameForParameterlessMethod)); var parameterizedStepDefinition = new StepDefinition(Reflection.GetMethod(typeof(ValidStepDefinitions), "WithArguments")); var fullNameForParameterizedMethod = typeof(ValidStepDefinitions).FullName + "." + parameterizedStepDefinition.Method.Name + "(Int32)"; Assert.That(parameterizedStepDefinition.Id, Is.EqualTo(fullNameForParameterizedMethod)); }
/// <summary> /// Defines a step in the current scenario. /// </summary> /// <param name="text">The step text.</param> /// <param name="body">The action that will perform the step.</param> /// <returns> /// An instance of <see cref="IStepBuilder"/>. /// </returns> public static IStepBuilder x(this string text, Func <Task> body) { var stepDef = new StepDefinition { Text = text, Body = body == null ? NullBodyCallback : c => body(), }; CurrentThread.Add(stepDef); return(stepDef); }
private List <string> GenerateScriptsThisStep(StepDefinition stepDef, int stepNo) { if (stepDef.Volume == "" || stepDef.Volume.Trim() == "0") { return new List <string>() { } } ; //use r command for simplicity if (double.Parse(stepDef.TipType) * 0.9 > double.Parse(stepDef.Volume)) { return(GenerateRCommnad(stepDef, stepNo)); } List <string> scripts = new List <string>(); scripts.Add(string.Format("C;{0}", stepDef.Description)); List <PipettingInfo> pipettingInfos = GetPipettingInfos(stepDef); int tipCountLiha = int.Parse(ConfigurationManager.AppSettings["tipCount"]); int tipReusedTimes = 0; int maxTipReuseTimes = int.Parse(stepDef.ReuseTimes); while (pipettingInfos.Count > 0) { int srcWellID = pipettingInfos[0].srcWellID; var sameSourceWellPipettingInfos = pipettingInfos.Where(x => x.srcWellID == srcWellID); pipettingInfos = pipettingInfos.Except(sameSourceWellPipettingInfos).ToList(); tipReusedTimes = 0; bool bNeedWash = false; foreach (var pipettingInfo in sameSourceWellPipettingInfos) { scripts.Add(GetAspirate(pipettingInfo.srcLabware, pipettingInfo.srcWellID, pipettingInfo.volume, stepDef.LiquidClass)); scripts.Add(GetDispense(pipettingInfo.dstLabware, pipettingInfo.dstWellID, pipettingInfo.volume, stepDef.LiquidClass)); tipReusedTimes++; bNeedWash = tipReusedTimes % maxTipReuseTimes == 0; if (bNeedWash) { scripts.Add("W;"); } } scripts.Add("W;"); } return(scripts); }
/// <summary> /// Defines a step in the current scenario. /// </summary> /// <param name="text">The step text.</param> /// <param name="body">The action that will perform the step.</param> /// <returns> /// An instance of <see cref="IStepBuilder"/>. /// </returns> public static IStepBuilder x(this string text, Action <IStepContext> body) { var stepDef = new StepDefinition { Text = text, Body = body == null ? NullBodyCallback : c => { body(c); return(Task.FromResult(0)); }, }; CurrentThread.Add(stepDef); return(stepDef); }
private StepDefinition CreateStepDefinition(IStepDefinitionBinding sdb, WarningCollector warningCollector) { var stepDefinition = new StepDefinition { Type = sdb.StepDefinitionType.ToString(), Regex = sdb.Regex?.ToString(), Method = sdb.Method.ToString(), ParamTypes = GetParamTypes(sdb.Method), Scope = GetScope(sdb), SourceLocation = GetSourceLocation(sdb.Method, warningCollector), Expression = GetSourceExpression(sdb), Error = GetError(sdb) }; return(stepDefinition); }
private bool StateMachine_Complete(StepDefinition currentStep) { // clear out any old connections if (IsOpen) { IsConnected = false; CurrentConnection?.Disconnect(); RunConnectionUpdate(); } if (WorkerState.ThreadClosing) { WorkerState.StateMachineComplete = true; } return(StepReturn.RepeatStep); }
/// <summary> /// Defines a step in the current scenario. /// </summary> /// <param name="text">The step text.</param> /// <param name="body">The action that will perform the step.</param> /// <returns> /// An instance of <see cref="IStepBuilder"/>. /// </returns> public static IStepBuilder x(this string text, Action <IStepContext> body) { var stepDefinition = new StepDefinition { Text = text, Body = body == null ? default(Func <IStepContext, Task>) : c => { body(c); return(Task.FromResult(0)); }, }; CurrentThread.StepDefinitions.Add(stepDefinition); return(stepDefinition); }