Inheritance: StoryTeller.Model.Node
        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 CellResult ProcessStep(StepValues step, ISpecContext context, object target)
        {
            var actual = step.Get(_property.Name);
            _property.SetValue(target, actual);

            return CellResult.Ok(_property.Name);
        }
        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 element = _config.Finder(SearchContext);
            StoryTellerAssert.Fail(element == null, "Could not find an element w/ description: " + _config.Description);

            return execute(element, values);
        }
        private void expectedRow(string id, int x, int y)
        {
            var values = new StepValues(id);
            values.Store("x", x);
            values.Store("y", y);

            _expected.Add(values);
        }
        private void actualRow(int x, int y)
        {
            var values = new StepValues(null);
            values.Store("x", x);
            values.Store("y", y);

            _actual.Add(values);
        }
Beispiel #7
0
        protected override IEnumerable<CellResult> execute(IWebElement element, StepValues values)
        {
            assertCondition(element.Enabled, DisabledElementMessage);
            assertCondition(element.Displayed, HiddenElementMessage);

            element.Click();

            return new [] { CellResult.Ok(Cell.Key) };
        }
Beispiel #8
0
        public void happy_check_for_a_simple_equals_match()
        {
            var values = new StepValues("1");

            values.Store("a", 1);

            Cell.For<int>("a").Check(values, 1)
                .ShouldBe(CellResult.Success("a"));
        }
Beispiel #9
0
        public void sad_path_check_for_a_simple_equals_match()
        {
            var values = new StepValues("1");


            values.Store("a", 1);

            Cell.For<int>("a").Check(values, 2)
                .ShouldBe(CellResult.Failure("a", "2"));
        }
        public override IEnumerable<CellResult> Execute(StepValues values, ISpecContext context)
        {
            _target.BeforeLine();

            var results = _properties.Select(x => x.ProcessStep(values, context, _target)).ToArray();

            _target.AfterLine();

            return results;
        }
        public Task<StepValues[]> Fetch(ISpecContext context)
        {
            return Task.Factory.StartNew(() => _source(context).Select(x =>
            {
                var values = new StepValues("actual");
                values.Store(_key, x);

                return values;

            }).ToArray());
        }
        protected override void processMatch(StepValues actual, SetVerificationResult result, StepValues expected)
        {
            actual.IsMatched = true;

            if (expected.Order == actual.Order)
            {
                base.processMatch(actual, result, expected);
            }
            else
            {
                result.MarkWrongOrder(expected.id, actual.Order);
            }
        }
        public void execute_happy()
        {
            var grammar = ValueCheckMethod.For(new Target(), x => x.Fullname(null, null));
            var values = new StepValues("1");
            values.Store("first", "Mat");
            values.Store("last", "Cauthon");
            values.Store("expected", "Mat Cauthon");

            var context = SpecContext.ForTesting();
            var result = grammar.Execute(values, context).Single();

            result.cell.ShouldBe("expected");
            result.Status.ShouldBe(ResultStatus.success);
        }
        public void process_delayed_runtime_convertor_that_fails_with_a_null()
        {
            var context = SpecContext.ForTesting();
            var values = new StepValues("1");

            values.RegisterDelayedConversion("a", "1", new StubRuntimeConverter("1", null));

            values.DoDelayedConversions(context);

            var result = values.Errors.Single().ShouldBeOfType<CellResult>();
            result.Status.ShouldBe(ResultStatus.error);
            result.cell.ShouldBe("a");
            result.error.ShouldContain("The converter was not able to create a value. Check the formatting.");
        }
        public void process_delayed_runtime_convertor_that_fails_with_exception()
        {
            var context = SpecContext.ForTesting();
            var values = new StepValues("1");

            values.RegisterDelayedConversion("a", "1", new StubRuntimeConverter("1", new NotImplementedException()));

            values.DoDelayedConversions(context);

            var result = values.Errors.Single().ShouldBeOfType<CellResult>();
            result.Status.ShouldBe(ResultStatus.error);
            result.cell.ShouldBe("a");
            result.error.ShouldContain("NotImplementedException");
        }
        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)} };
            }
        }
        public void execute()
        {
            var grammar = ActionMethodGrammar.Create(x => x.Go(null, 0, 0), theTarget);
            grammar.Compile(new Fixture(), CellHandling.Basic()).ShouldBeOfType<Sentence>();

            var values = new StepValues("id");
            values.Store("name", "Jeremy");
            values.Store("age", 41);
            values.Store("percentAwake", 50.1);

            ShouldBeTestExtensions.ShouldBe(grammar.Execute(values, SpecContext.Basic()).Any(), false);

            theTarget.Name.ShouldBe("Jeremy");
            theTarget.Age.ShouldBe(41);
            theTarget.PercentAwake.ShouldBe(50.1);
        }
        public IEnumerable<CellResult> Invoke(StepValues values)
        {
            var parameters = _arguments.Select(values.Get).ToArray();
            var returnValue = _method.Invoke(_target, parameters);

            foreach (var output in _outputs)
            {
                var actual = parameters[output.Position];
                yield return output.Check(values, actual);
            }

            if (ReturnCell != null)
            {
                yield return ReturnCell.Check(values, returnValue);
            }
        }
        public override IEnumerable<CellResult> Execute(StepValues values, ISpecContext context)
        {
            var element = _config.Finder(SearchContext);
            StoryTellerAssert.Fail(element == null, "Could not find an element w/ description: " + _config.Description);

            try
            {
                return execute(element, values);
            }
            catch (Exception ex)
            {
                // TODO: Use exception metadata with and add a custom exception formatter to show exception metadata
                //       See: https://github.com/storyteller/Storyteller/issues/400
                // ex.Data.Add("Gesture Description", _config.Description);
                throw new Exception("Gesture failed. [Description: {0}]".ToFormat(_config.Description), ex);
            }
        }
        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 void invoke_with_return_value()
        {
            var target = new Target();
            var method = ReflectionHelper.GetMethod<Target>(x => x.Fullname(null, null, null));

            var values = new StepValues(method.Name);
            values.Store("first", "Jeremy");
            values.Store("middle", "Daniel");
            values.Store("last", "Miller");
            values.Store("returnValue", "foo");

            var invocation = new MethodInvocation(method, target);
            invocation.Compile(target, CellHandling.Basic());

            invocation.Invoke(values).Single().actual.ShouldBe("Jeremy Daniel Miller");

        }
Beispiel #22
0
        public void use_a_runtime_converter_with_a_value()
        {
            var conversions = new Conversions();
            conversions.RegisterRuntimeConversion<ColorConverter>();

            var cellHandling = new CellHandling(new EquivalenceChecker(), conversions);

            var cell = new Cell(cellHandling, "color", typeof (Color));

            var values = new StepValues("foo");
            cell.ConvertValues(new Step("foo").With("color", "Red"), values);

            var delayed = values.DelayedConversions.Single();

            delayed.Key.ShouldBe("color");
            delayed.Raw.ShouldBe("Red");
            delayed.Converter.ShouldBeOfType<ColorConverter>();
        }
        public void execute()
        {
            var target = new Target();
            var method = ReflectionHelper.GetMethod<Target>(x => x.Go(null, 0, 0));
            var invocation = new MethodInvocation(method, target);

            var values = new StepValues(method.Name);

            values.Store("name", "Jeremy");
            values.Store("age", 41);
            values.Store("percentAwake", 50.1);

            invocation.Invoke(values).ToArray();

            target.Name.ShouldBe("Jeremy");
            target.Age.ShouldBe(41);
            target.PercentAwake.ShouldBe(50.1);
        }
        public void apply_ordering()
        {
            var values = new StepValues[]
            {
                new StepValues(Guid.NewGuid().ToString()),
                new StepValues(Guid.NewGuid().ToString()),
                new StepValues(Guid.NewGuid().ToString()),
                new StepValues(Guid.NewGuid().ToString()),
                new StepValues(Guid.NewGuid().ToString()),
                new StepValues(Guid.NewGuid().ToString())
            };

            values.ApplyOrdering();

            for (var i = 0; i < values.Length; i++)
            {
                values[i].Order.ShouldBe(i + 1);
            }

        }
        public void MarkExtra(StepValues values)
        {
            var extra = new Dictionary<string, string>();
            values.RawData.Each(pair =>
            {
                if (pair.Value == null)
                {
                    extra.Add(pair.Key, "NULL");
                }
                else if (pair.Value == string.Empty)
                {
                    extra.Add(pair.Key, "BLANK");
                }
                else
                {
                    extra.Add(pair.Key, pair.Value.ToString());
                }
            });

            _extras.Add(extra);
        }
        public void invoke_with_out_parameters_happy_path()
        {
            var age = 0;
            double percentAwake = 0;

            var target = new Target();
            var method = ReflectionHelper.GetMethod<Target>(x => x.GoOutput(null, out age, out percentAwake));

            var values = new StepValues(method.Name);
            values.Store("name", "Grace Potter");
            values.Store("age", 5);
            values.Store("percentAwake", .5);

            var invocation = new MethodInvocation(method, target);
            invocation.Compile(target, CellHandling.Basic());

            var results = invocation.Invoke(values).ToArray();

            results.ShouldHaveTheSameElementsAs(
                new CellResult("age", ResultStatus.success),
                new CellResult("percentAwake", ResultStatus.success)
            );
        }
Beispiel #27
0
 public abstract IEnumerable<CellResult> Execute(StepValues values, ISpecContext context);
 public bool InvokeTest(StepValues values)
 {
     var parameters = _arguments.Select(values.Get).ToArray();
     return (bool) _method.Invoke(_target, parameters);
 }
Beispiel #29
0
 public FactPlan(StepValues values, IFactGrammar grammar) : base(values)
 {
     _grammar = grammar;
 }
Beispiel #30
0
 public bool PerformTest(StepValues values, ISpecContext context)
 {
     return _test(context);
 }