Example #1
0
        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");
        }
Example #2
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"));
        }
Example #3
0
        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 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 Task <StepValues[]> Fetch(ISpecContext context)
        {
            return(Task.Factory.StartNew(() => _source(context).Select(x =>
            {
                var values = new StepValues("actual");
                _matches.Each(a => values.Store(a.Name, a.GetValue(x)));

                return values;
            }).ToArray()));
        }
Example #6
0
        public void csv_value_if_explicit()
        {
            var cell   = Cell.For <string>("foo");
            var values = new StepValues(Guid.NewGuid().ToString());

            values.Store(cell.Key, "bar");

            cell.CsvValue(new Section("container"), values)
            .ShouldBe("bar");
        }
        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()));
        }
Example #8
0
        public async Task invoke_with_return_value_with_async_invocation()
        {
            var target = new Target();
            var method = ReflectionHelper.GetMethod <Target>(x => x.FullnameAsync(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 AsyncMethodInvocationWithReturn <string>(method, target);

            invocation.Compile(target, CellHandling.Basic());

            var results = await invocation.InvokeAsync(values);

            results.Single().actual.ShouldBe("Jeremy Daniel Miller");
        }
Example #9
0
        public void use_explicit_value_if_column_is_optional_and_active()
        {
            var cell = Cell.For <string>("foo");

            cell.As <ICellExpression>().UseDefaultIfNotExplicitlyExpressed("the default");

            var values = new StepValues(Guid.NewGuid().ToString());

            values.Store(cell.Key, "bar");

            var section = new Section("container");

            cell.CsvValue(section, values)
            .ShouldBe("bar");
        }
Example #10
0
        public void csv_value_if_omit_when_inactive_and_is_active()
        {
            var cell = Cell.For <string>("foo");

            cell.As <ICellExpression>().OmitIfInactive();

            var values = new StepValues(Guid.NewGuid().ToString());

            values.Store(cell.Key, "bar");

            var section = new Section("container");

            section.IsCellActive(cell).ShouldBeTrue();

            cell.CsvValue(section, values)
            .ShouldBe("bar");
        }
        public void matches_array_()
        {
            var cell    = new Cell(CellHandling.Basic(), "a", typeof(int[]));
            var values1 = new StepValues("foo");

            values1.Store(cell.Key, new[] { 1, 2, 3 });

            var values2 = new StepValues("foo");

            values2.Store(cell.Key, new[] { 1, 2, 3 });

            var values3 = new StepValues("foo");

            values3.Store(cell.Key, new[] { 1, 2, 4 });

            cell.Matches(values1, values2).ShouldBe(true);
            cell.Matches(values1, values3).ShouldBe(false);
        }
        public void matches_simply()
        {
            var cell    = new Cell(CellHandling.Basic(), "a", typeof(int));
            var values1 = new StepValues("foo");

            values1.Store(cell.Key, 5);

            var values2 = new StepValues("foo");

            values2.Store(cell.Key, 5);

            var values3 = new StepValues("foo");

            values3.Store(cell.Key, 6);

            cell.Matches(values1, values2).ShouldBe(true);
            cell.Matches(values1, values3).ShouldBe(false);
        }
Example #13
0
        public void can_invoke_a_method_returning_task()
        {
            var target = new Target();
            var method = ReflectionHelper.GetMethod <Target>(x => x.GoOutputAsync(null));

            var values = new StepValues(method.Name);

            values.Store("name", "Bill");

            var invocation = MethodInvocation.For(method, target);

            invocation.Compile(target, CellHandling.Basic());

            invocation.IsAsync().ShouldBeTrue();

            invocation.InvokeAsync(values).Wait();

            target.Name.ShouldBe("Bill");
        }