Esempio n. 1
0
        public void runs_all_the_delayed_conversions_before_performing_the_action()
        {
            var c1 = new FakeRuntimeConverter();
            var c2 = new FakeRuntimeConverter();

            values.RegisterDelayedConversion("a", "1", c1);
            values.RegisterDelayedConversion("b", "2", c2);

            theLineGrammar.Expect(x => x.Execute(values, context)).Return(new CellResult[0]);

            afterExecuting();

            theLineGrammar.VerifyAllExpectations();

            ShouldBeTestExtensions.ShouldBe(c1.ConversionHappened, true);
            ShouldBeTestExtensions.ShouldBe(c2.ConversionHappened, true);
        }
        public void runs_all_the_delayed_conversions_before_performing_the_action()
        {
            var c1 = new FakeRuntimeConverter();
            var c2 = new FakeRuntimeConverter();

            values.RegisterDelayedConversion("a", "1", c1);
            values.RegisterDelayedConversion("b", "2", c2);

            theLineGrammar.Execute(values, context).Returns(new CellResult[0]);

            afterExecuting();

            theLineGrammar.Received().Execute(values, context);

            c1.ConversionHappened.ShouldBe(true);
            c2.ConversionHappened.ShouldBe(true);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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.");
        }
Esempio n. 5
0
        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");
        }