Beispiel #1
0
        public async Task can_alter_and_registry_still_gets_defaults()
        {
            var app = new MyApp();

            app.Configuration.AddJsonFile("appsettings.json")
            .AddJsonFile("colors.json");

            app.Settings.Require <Colors>();
            app.Settings.Alter <MyFakeSettings>(_ => { _.SomeSetting = 29; });

            var runtime = await JasperRuntime.ForAsync(app);

            try
            {
                var mySettings = runtime.Get <MyFakeSettings>();
                var colors     = runtime.Get <Colors>();

                mySettings.SomeSetting.ShouldBe(29);
                colors.Red.ShouldBe("#ff0000");
            }
            finally
            {
                await runtime.Shutdown();
            }
        }
        public void can_modify_registry()
        {
            var app     = new MyApp();
            var runtime = JasperRuntime.For(app);
            var myApp   = (MyApp)runtime.Registry;

            myApp.MySetting.ShouldBe(true);
        }
Beispiel #3
0
        public void can_modify_registry()
        {
            var app = new MyApp();

            using (var runtime = JasperRuntime.For(app))
            {
                app.MySetting.ShouldBe(true);
            }
        }
Beispiel #4
0
        public async Task can_modify_registry()
        {
            var app = new MyApp();

            var runtime = await JasperRuntime.ForAsync(app);

            try
            {
                app.MySetting.ShouldBe(true);
            }
            finally
            {
                await runtime.Shutdown();
            }
        }
        public void can_alter_and_registry_still_gets_defaults()
        {
            var app = new MyApp();

            app.Configuration.AddJsonFile("appsettings.json")
            .AddJsonFile("colors.json");

            app.Settings.Require <Colors>();
            app.Settings.Alter <MyFakeSettings>(_ => { _.SomeSetting = 29; });

            using (var runtime = JasperRuntime.For(app))
            {
                var mySettings = runtime.Get <MyFakeSettings>();
                var colors     = runtime.Get <Colors>();

                mySettings.SomeSetting.ShouldBe(29);
                colors.Red.ShouldBe("#ff0000");
            }
        }
        public void can_alter_and_registry_still_gets_defaults()
        {
            var app = new MyApp();

            app.Settings.Build(_ =>
            {
                _.AddJsonFile("appsettings.json");
                _.AddJsonFile("colors.json");
            });

            app.Settings.Configure <Colors>();
            app.Settings.Alter <MySettings>(_ =>
            {
                _.SomeSetting = 29;
            });

            var runtime    = JasperRuntime.For(app);
            var container  = new Container(runtime.Registry.Services);
            var mySettings = container.GetInstance <MySettings>();
            var colors     = container.GetInstance <Colors>();

            mySettings.SomeSetting.ShouldBe(29);
            colors.Red.ShouldBe("#ff0000");
        }