public void Test_Kernel_AddFacility()
        {
            var kernel = new DefaultKernel();

            kernel.AddFacility <LoggingFacility>(
                f => f.LogUsing(LoggerImplementation.NLog).WithConfig("LoggingFacility\\NLog.facilities.test.config"));
        }
Example #2
0
		public void AddingComponentToRootKernelWhenChildKernelHasStartableFacility()
		{
			IKernel kernel = new DefaultKernel();
			IKernel childKernel = new DefaultKernel();
			kernel.AddChildKernel(childKernel);
			childKernel.AddFacility(new StartableFacility());
			kernel.Register(Component.For(typeof (A)).Named("string")); // exception here
		}
 public void AddingComponentToRootKernelWhenChildKernelHasStartableFacility()
 {
     IKernel kernel = new DefaultKernel();
     IKernel childKernel = new DefaultKernel();
     kernel.AddChildKernel(childKernel);
     childKernel.AddFacility("StartableFacility", new StartableFacility());
     kernel.AddComponent("string", typeof(String)); // exception here
 }
Example #4
0
        public void AddingComponentToRootKernelWhenChildKernelHasStartableFacility()
        {
            IKernel kernel      = new DefaultKernel();
            IKernel childKernel = new DefaultKernel();

            kernel.AddChildKernel(childKernel);
            childKernel.AddFacility(new StartableFacility());
            kernel.Register(Component.For(typeof(String)).Named("string"));             // exception here
        }
        public void Test_DefaultKernel_AddFacility()
        {
            var facility = new LoggingFacility();

            facility.LogUsing(LoggerImplementation.NLog).WithConfig("LoggingFacility\\NLog.facilities.test.config");
            Assert.AreEqual(facility.GetType().FullName, "Castle.Facilities.Logging.LoggingFacility");
            var kernel = new DefaultKernel();

            kernel.AddFacility(facility);
        }
Example #6
0
        public void Test_Kernal()
        {
            IKernel kernel = new DefaultKernel();

            kernel.ConfigurationStore = new DefaultConfigurationStore();
            var configFile = GetConfigFile(LoggerImplementation.ExtendedLog4net);

            kernel.AddFacility <LoggingFacility>(
                (f => f.LogUsing(LoggerImplementation.ExtendedLog4net).WithConfig(configFile)));
            Assert.IsNotNull(kernel);
        }
        public void Test_DefaultKernel_AddFacility2()
        {
            var facility = new LoggingFacility();

            facility.LogUsing(LoggerImplementation.NLog).WithConfig("LoggingFacility\\NLog.facilities.test.config");
            var kernel = new DefaultKernel();

#pragma warning disable 612, 618
            kernel.AddFacility("Castle.Facilities.Logging.LoggingFacility", facility);
#pragma warning restore 612, 618
        }
Example #8
0
 public void FacilityConfig_is_not_null()
 {
     using (var c = new DefaultKernel())
     {
         const string facilityKey = "hiper";
         var          config      = new MutableConfiguration("facility");
         c.ConfigurationStore.AddFacilityConfiguration(facilityKey, config);
         var facility = new HiperFacility();
         c.AddFacility(facilityKey, facility);
         Assert.IsTrue(facility.Initialized);
     }
 }
Example #9
0
        public void Test_Kernerl_AddFacility()
        {
            IKernel kernel = new DefaultKernel();

            kernel.ConfigurationStore = new DefaultConfigurationStore();
            var configFile = GetConfigFile(LoggerImplementation.ExtendedLog4net);
            Action <LoggingFacility> onCreate = f => f.LogUsing(LoggerImplementation.ExtendedLog4net).WithConfig(configFile);
            var facility = new LoggingFacility();

            onCreate.Invoke(facility);
            kernel.AddFacility(facility);
            Assert.IsNotNull(facility);
        }
Example #10
0
        public void Test_Kernel_AddFacility_WithFullName()
        {
            IKernel kernel = new DefaultKernel();

            kernel.ConfigurationStore = new DefaultConfigurationStore();
            var configFile = GetConfigFile(LoggerImplementation.ExtendedLog4net);
            Action <LoggingFacility> onCreate = f => f.LogUsing(LoggerImplementation.ExtendedLog4net).WithConfig(configFile);
            var facility = new LoggingFacility();

            onCreate.Invoke(facility);
#pragma warning disable 612, 618
            kernel.AddFacility("Castle.Facilities.Logging.LoggingFacility", facility);
#pragma warning restore 612, 618
            Assert.IsNotNull(facility);
        }
Example #11
0
        public void SetUp()
        {
            kernel = new DefaultKernel();

            kernel.AddFacility <StartableFacility>();

            kernel.Register(
                Component.For <StartableDisposableAndInitializableComponent>()
                .LifeStyle.Transient
                );

            component = kernel.Resolve <StartableDisposableAndInitializableComponent>();
            component.DoSomething();
            kernel.ReleaseComponent(component);

            calledMethods = component.calledMethods;
        }
Example #12
0
        public void TestInterfaceBasedStartable()
        {
            IKernel kernel = new DefaultKernel();

            kernel.AddFacility("startable", new StartableFacility());

            kernel.AddComponent("a", typeof(StartableComponent));

            StartableComponent component = kernel["a"] as StartableComponent;

            Assert.IsNotNull(component);
            Assert.IsTrue(component.Started);
            Assert.IsFalse(component.Stopped);

            kernel.ReleaseComponent(component);
            Assert.IsTrue(component.Stopped);
        }
Example #13
0
        public void TestComponentWithNoInterface()
        {
            IKernel kernel = new DefaultKernel();

            MutableConfiguration compNode = new MutableConfiguration("component");

            compNode.Attributes["id"]          = "b";
            compNode.Attributes["startable"]   = "true";
            compNode.Attributes["startMethod"] = "Start";
            compNode.Attributes["stopMethod"]  = "Stop";

            kernel.ConfigurationStore.AddComponentConfiguration("b", compNode);

            kernel.AddFacility("startable", new StartableFacility());
            kernel.AddComponent("b", typeof(NoInterfaceStartableComponent));
            NoInterfaceStartableComponent component = kernel["b"] as NoInterfaceStartableComponent;

            Assert.IsNotNull(component);
            Assert.IsTrue(component.Started);
            Assert.IsFalse(component.Stopped);

            kernel.ReleaseComponent(component);
            Assert.IsTrue(component.Stopped);
        }