示例#1
0
        public void TestStart()
        {
            IAppModule appModule = new TestAppModule();
            AppSetup   setup     = new AppSetup();
            var        app       = setup.Start(appModule);

            Debug.WriteLine("AppStarted");
            IComponentContainer componentContainer = app.GetAppContainer <IComponentContainer>();

            Assert.IsNotNull(componentContainer);
            Debug.WriteLine("Creating : {0}", typeof(Class2));
            Assert.IsNotNull(componentContainer.CreateComponent <Class2>());
            Debug.WriteLine("Created : {0}", typeof(Class2));
            Debug.WriteLine("Creating : {0}", typeof(Class2));
            Class2 cls2 = componentContainer.CreateComponent <Class2>();

            Debug.WriteLine("Created : {0}", typeof(Class2));
            Debug.WriteLine("Injecting : {0}", typeof(Class2));
            componentContainer.InjectProperties(cls2);
            Debug.WriteLine("Injected : {0}", typeof(Class2));

            int i = app.Context.GetOrCreate <int>("Index", key => 0);

            Assert.AreEqual(2, i);
            Assert.IsNotNull(cls2.Class1);
        }