public void Test_Kernel_AddFacility() { var kernel = new DefaultKernel(); kernel.AddFacility <LoggingFacility>( f => f.LogUsing(LoggerImplementation.NLog).WithConfig("LoggingFacility\\NLog.facilities.test.config")); }
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 }
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); }
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 }
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); } }
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); }
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); }
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; }
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); }
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); }