Store() 공개 메소드

public Store ( string key, object value ) : void
key string
value object
리턴 void
        private void actualRow(int x, int y)
        {
            var values = new StepValues(null);
            values.Store("x", x);
            values.Store("y", y);

            _actual.Add(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);
        }
        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 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);
        }
예제 #5
0
        public void store_and_retrieve()
        {
            var values = new StepValues("1");

            values.Store("a", 1);
            values.Get("a").ShouldBe(1);
        }
        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");

        }
        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);
        }
예제 #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"));
        }
예제 #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 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());
        }
        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)
            );
        }
        public void execute_sad()
        {
            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", "Rand Al'Thor");

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

            // The method is working correctly, but the 
            // test data should result in a failure
            result.cell.ShouldBe("expected");
            result.actual.ShouldBe("Mat Cauthon");
            result.Status.ShouldBe(ResultStatus.failed);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
        }