コード例 #1
0
        public void Init()
        {
            IAppModule appModule = new TAppModule();
            AppSetup   setup     = new AppSetup();

            this.App = setup.Start(appModule);
            IComponentContainer componentContainer = this.App.GetAppContainer <IComponentContainer>();

            ComponentContainer = componentContainer.BeginScope("TEST");
        }
コード例 #2
0
        public void Init()
        {
            Console.WriteLine("CommandBusTests.Init");
            IAppModule          appModule          = new TestAppModule();
            AppSetup            setup              = new AppSetup();
            var                 app                = setup.Start(appModule);
            IComponentContainer componentContainer = app.GetAppContainer <IComponentContainer>();

            ComponentContainer = componentContainer.BeginScope("TEST");
        }
コード例 #3
0
        public void RemoveService()
        {
            IAppModule          appModule          = new TestAppModule();
            AppSetup            setup              = new AppSetup();
            var                 app                = setup.Start(appModule);
            IComponentContainer componentContainer = app.GetAppContainer <IComponentContainer>();

            using (var scope = componentContainer.BeginScope("TEST"))
            {
                ICL1Service service = scope.CreateComponent <ICL1Service>();
                Assert.AreEqual("TEST", service.GetName());
            }
        }
コード例 #4
0
        public void GetServiceThatRegistedByTestAppModule()
        {
            IAppModule          appModule          = new TestAppModule();
            AppSetup            setup              = new AppSetup();
            var                 app                = setup.Start(appModule);
            IComponentContainer componentContainer = app.GetAppContainer <IComponentContainer>();

            using (var scope = componentContainer.BeginScope("test"))
            {
                ServiceRegistedByAppModule service
                    = scope.CreateComponent <ServiceRegistedByAppModule>();
                Assert.IsNotNull(service);
                Assert.IsInstanceOfType(service, typeof(DefaultServiceRegistedByAppModule));
            }
        }
コード例 #5
0
        public void TestConfigWithFileNotExists()
        {
            IAppModule          appModule          = new TestAppModule();
            AppSetup            setup              = new AppSetup("./abc.json");
            var                 app                = setup.Start(appModule);
            IComponentContainer componentContainer = app.GetAppContainer <IComponentContainer>();

            using (var scope = componentContainer.BeginScope("test"))
            {
                TestConfig config1 = scope.CreateComponent <TestConfig>();
                TestConfig config2 = scope.CreateComponent <TestConfig>();
                Assert.AreEqual("Mode", config1.Mode);
                Assert.AreEqual(config1, config2);
            }
        }
コード例 #6
0
        public override void OnAppStarted(App app)
        {
            IComponentContainer componentContainer = app.GetAppContainer <IComponentContainer>();

            using (var scope = componentContainer.BeginScope("GenerateJsonSchema"))
            {
                AppConfig appConfig = scope.CreateComponent <AppConfig>();
                if (!appConfig.GenerateConfigJsonSchema)
                {
                    return;
                }
                IJsonSchemaGenerator generator = scope.CreateComponent <IJsonSchemaGenerator>();
                string json = generator.Generate(this.registions);
                string path = this.configFilePath.Replace(".json", ".schema.json");
                File.WriteAllText(path, json);
            }
        }