Beispiel #1
0
        protected virtual GeneratorBootstrapper CreateBootstrapper(Action <IScaffoldBuilder> configurationAction)
        {
            var helper = new TestHelper {
                ScaffoldAction = configurationAction
            };

            var factory = new TestBootstrapperFactory(bootstrapper => bootstrapper.RegisterConvention(
                                                          new ActionBasedServiceConfigurationConvention(s => s.AddSingleton(helper))));

            return(factory.Create(BootstrapperHelper.CreateTestContext <TestGenerator>()));
        }
        public void test_simple_list_option_two()
        {
            var helper  = new TestHelper();
            var context =
                BootstrapperHelper.CreateTestContext <TestGenerator>(x => x.Arguments = new[] { "bar" });

            new TestBootstrapperFactory(
                x =>
                x.RegisterConvention(new ActionBasedServiceConfigurationConvention(s => s.AddSingleton(helper))))
            .Create(context).Execute(new GeneratorExecutor());

            Assert.Equal("bar", helper.Stream.ReadAsString());
        }
Beispiel #3
0
        public void test_simple()
        {
            var helper = new TestHelper();
            helper.OptionsAction = (factory, options) => options.Choice1 = "foo";

            var context = BootstrapperHelper.CreateTestContext<TestGenerator>();
            new TestBootstrapperFactory(strapper =>
                strapper.RegisterConvention(
                    new ActionBasedServiceConfigurationConvention(s => s.AddSingleton(helper)
                        .AddSingleton<TestGeneratorOptions>().AddSingleton<IScaffoldConfigurer, TestScaffolderConfigurer>()))).Create(context).Execute();

            Assert.Equal("foo", helper.Stream1.ReadAsString());
        }
        public void test_dependent_generator()
        {
            var helper  = new TestHelper();
            var context =
                BootstrapperHelper.CreateTestContext <TestGenerator>(x => x.Arguments = new[] { "foo", "AreBelongToUs" });

            new TestBootstrapperFactory(
                x =>
                x.RegisterConvention(new ActionBasedServiceConfigurationConvention(s => s.AddSingleton(helper).AddScoped <DependentGenerator>())))
            .Create(context).Execute(new GeneratorExecutor());

            Assert.Equal("foo", helper.Stream1.ReadAsString());
            Assert.Equal("AreBelongToUs", helper.Stream2.ReadAsString());
        }
Beispiel #5
0
        public void test_combined_options_one()
        {
            var helper  = new TestHelper();
            var context =
                BootstrapperHelper.CreateTestContext <TestGenerator>(x => x.Arguments = new[] { "foo", "base" });

            new TestBootstrapperFactory(
                x =>
                x.RegisterConvention(new ActionBasedServiceConfigurationConvention(s => s.AddSingleton(helper))))
            .Create(context).Execute();

            Assert.Equal("base", helper.Stream2.ReadAsString());
            Assert.Equal("AllYourBase", helper.Stream1.ReadAsString());
        }