/// <summary> /// Used internally /// </summary> /// <param name="cell"></param> /// <param name="section"></param> /// <param name="values"></param> /// <returns></returns> public static string CsvValue(this Cell cell, Section section, StepValues values) { var requirement = cell.CsvRequirement(); switch (requirement) { case CsvRequired.Required: return((string)values.Get(cell.Key)); case CsvRequired.OmitIfInactive: return((string)(section.IsCellActive(cell) ? values.Get(cell.Key) : null)); case CsvRequired.UseDefaultIfNotExplicitlyExpressed: if (section.IsCellActive(cell)) { return((string)values.Get(cell.Key)); } else if (cell.Metadata.ContainsKey(CsvValueBuilderKey)) { var builder = cell.Metadata[CsvValueBuilderKey].As <Func <StepValues, string> >(); return(builder(values)); } else if (cell.HasDefault()) { return(cell.DefaultValue.ToFormat(values.Order)); } else { return(string.Empty); } } return(null); }
public void store_and_retrieve() { var values = new StepValues("1"); values.Store("a", 1); values.Get("a").ShouldBe(1); }
public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context) { var value = values.Get(_cell.Key); context.State.CurrentObject.SetValue(Members, value); return(Enumerable.Empty <CellResult>()); }
protected override IEnumerable <CellResult> execute(IWebElement element, StepValues values) { var handler = ElementHandlers.FindHandler(element); handler.EnterData(SearchContext, element, values.Get(Cell.Key)); return(new [] { CellResult.Ok(Cell.Key) }); }
public void process_delayed_runtime_converters_successfully() { var context = SpecContext.ForTesting(); var values = new StepValues("1"); values.RegisterDelayedConversion("a", "1", new StubRuntimeConverter("1", 1)); values.RegisterDelayedConversion("b", "2", new StubRuntimeConverter("2", 2)); values.RegisterDelayedConversion("c", "3", new StubRuntimeConverter("3", 3)); values.DoDelayedConversions(context); values.Get("a").ShouldBe(1); values.Get("b").ShouldBe(2); values.Get("c").ShouldBe(3); ShouldBeTestExtensions.ShouldBe(values.Errors.Any(), false); }
public CellResult ProcessStep(StepValues step, ISpecContext context, object target) { var actual = step.Get(_property.Name); _property.SetValue(target, actual); return(CellResult.Ok(_property.Name)); }
public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context) { var input = (TInput)values.Get(_key); var @object = _creator(input); context.State.CurrentObject = @object; return(new[] { CellResult.Ok(_key) }); }
public CellResult Check(StepValues values, object actual) { // TODO: Could be Predicate<T> -- figure out how to use this var expected = values.Get(Key); return(_equivalence(expected, actual) ? CellResult.Success(Key) : CellResult.Failure(Key, ToStringDisplay(actual))); }
public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context) { var input = values.Get(_key).As <TInput>(); var @object = context.State.CurrentObject.As <TObject>(); _configure(@object, @input); return(Enumerable.Empty <CellResult>()); }
public bool Matches(StepValues one, StepValues two) { if (!one.Has(Key) || !two.Has(Key)) { return(false); } var v1 = one.Get(Key); var v2 = two.Get(Key); return(_equivalence(v1, v2)); }
public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context) { var actual = _accessor.GetValue(context.State.CurrentObject); var expected = values.Get(_cell.Key); if (expected.Equals(actual)) { yield return(CellResult.Success(_cell.Key)); } else { yield return(CellResult.Failure(_cell.Key, actual.ToString())); } }
public void use_a_runtime_converter_against_NULL() { var cellHandling = CellHandling.Basic(); cellHandling.RegisterRuntimeConversion <ColorConverter>(); var cell = new Cell(cellHandling, "color", typeof(Color)); var values = new StepValues("foo"); cell.ConvertValues(new Step("foo").With("color", "NULL"), values); values.Get("color").ShouldBeNull(); }
public override async Task <IEnumerable <CellResult> > ExecuteAsync(StepValues values, ISpecContext context) { var dict = new Dictionary <string, object> { { "type", _type } }; foreach (var cell in _cells) { dict.Add(cell.Key, values.Get(cell.Key)); } await _fixture.sendAction(dict).ConfigureAwait(false); return(new CellResult[0]); }
public void cell_uses_the_default_for_conversion_when_no_value_exists() { var cell = Cell.For <CellTarget>(x => x.Number); cell.DefaultValue = "111"; var values = new StepValues("foo"); var step = new Step("key"); //.With("Number", "a"); cell.ConvertValues(step, values); values.Errors.Any().ShouldBe(false); values.Get("Number").ShouldBe(111); }
public void AddParameter(IDbCommand command, StepValues values) { var value = values.Get(Cell.Key); var param = command.CreateParameter(); configureParameter(param); param.ParameterName = ParameterName; param.Direction = Direction; if (Direction != ParameterDirection.Output) { param.Value = value; } command.Parameters.Add(param); }
protected override IEnumerable <CellResult> execute(IWebElement element, StepValues values) { var handler = ElementHandlers.FindHandler(element); var expectedValue = values.Get(Cell.Key); var matchingHandler = handler as IMatchingHandler ?? new BasicMatchingHandler(handler); if (matchingHandler.MatchesData(element, expectedValue)) { return(new [] { new CellResult(Cell.Key, ResultStatus.success) }); } else { return(new [] { new CellResult(Cell.Key, ResultStatus.failed) { actual = handler.GetData(SearchContext, element) } }); } }