Esempio n. 1
0
        public void Execute(SpecContext context)
        {
            using (context.Timings.Subject(Type, Subject))
            {
                Values.DoDelayedConversions(context);

                if (Values.Errors.Any())
                {
                    var result = Values.ToConversionErrorResult();
                    result.position = Position;

                    context.LogResult(result);

                    return;
                }

                try
                {
                    var result = execute(context);

                    result.position = Position;

                    context.LogResult(result);
                }
                catch (Exception ex)
                {
                    context.LogException(Values.id, ex, Position);
                }
            }
        }
Esempio n. 2
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");
        }
Esempio n. 3
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. 4
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);
        }