public void ParametersAndServicesBestCase2() { DefaultConfigurationStore store = new DefaultConfigurationStore(); MutableConfiguration config = new MutableConfiguration("component"); MutableConfiguration parameters = (MutableConfiguration) config.Children.Add(new MutableConfiguration("parameters")); parameters.Children.Add(new MutableConfiguration("name", "hammett")); parameters.Children.Add(new MutableConfiguration("port", "120")); parameters.Children.Add(new MutableConfiguration("Scheduleinterval", "22")); store.AddComponentConfiguration("service", config); kernel.ConfigurationStore = store; kernel.AddComponent("a", typeof(A)); kernel.AddComponent("service", typeof(ServiceUser2)); ServiceUser2 service = (ServiceUser2)kernel["service"]; Assert.IsNotNull(service); Assert.IsNotNull(service.AComponent); Assert.IsNull(service.BComponent); Assert.IsNull(service.CComponent); Assert.AreEqual("hammett", service.Name); Assert.AreEqual(120, service.Port); Assert.AreEqual(22, service.ScheduleInterval); }
public void ProperDeserialization() { DefaultConfigurationStore store = new DefaultConfigurationStore(); XmlInterpreter interpreter = new XmlInterpreter(new ConfigResource()); interpreter.ProcessResource(interpreter.Source, store); Assert.AreEqual(2, store.GetFacilities().Length); Assert.AreEqual(2, store.GetComponents().Length); IConfiguration config = store.GetFacilityConfiguration("testidengine"); IConfiguration childItem = config.Children["item"]; Assert.IsNotNull(childItem); Assert.AreEqual("value", childItem.Value); config = store.GetFacilityConfiguration("testidengine2"); Assert.IsNotNull(config); Assert.AreEqual("value within CDATA section", config.Value); config = store.GetComponentConfiguration("testidcomponent1"); childItem = config.Children["item"]; Assert.IsNotNull(childItem); Assert.AreEqual("value1", childItem.Value); config = store.GetComponentConfiguration("testidcomponent2"); childItem = config.Children["item"]; Assert.IsNotNull(childItem); Assert.AreEqual("value2", childItem.Value); }
public void SimpleCase() { String contents = "import Castle.Facilities.AspectSharp.Tests.Components in Castle.Facilities.AspectSharp.Tests " + "import Castle.Facilities.AspectSharp.Tests.Interceptors in Castle.Facilities.AspectSharp.Tests " + " " + " aspect MyAspect for SimpleService " + " " + " pointcut method|property(*)" + " advice(LoggerInterceptor)" + " end" + " " + " end "; MutableConfiguration config = new MutableConfiguration("facility", contents); DefaultConfigurationStore store = new DefaultConfigurationStore(); store.AddFacilityConfiguration("aop", config); WindsorContainer container = new WindsorContainer(store); container.AddFacility("aop", new AspectSharpFacility()); container.AddComponent("comp1", typeof(SimpleService)); SimpleService service = container[typeof(SimpleService)] as SimpleService; service.DoSomething(); service.DoSomethingElse(); Assert.AreEqual("Enter DoSomething\r\nEnter DoSomethingElse\r\n", LoggerInterceptor.Messages.ToString()); }
public void ParametersAndServicesBestCase() { var store = new DefaultConfigurationStore(); var config = new MutableConfiguration("component"); var parameters = new MutableConfiguration("parameters"); config.Children.Add(parameters); parameters.Children.Add(new MutableConfiguration("name", "hammett")); parameters.Children.Add(new MutableConfiguration("port", "120")); store.AddComponentConfiguration("service", config); Kernel.ConfigurationStore = store; Container.Register(Component.For <A>().Named("a"), Component.For <ServiceUser2>().Named("service")); var service = Container.Resolve <ServiceUser2>("service"); Assert.IsNotNull(service); Assert.IsNotNull(service.AComponent); Assert.IsNull(service.BComponent); Assert.IsNull(service.CComponent); Assert.AreEqual("hammett", service.Name); Assert.AreEqual(120, service.Port); }
public void OperationsLocked() { IConfigurationStore configurationStore = new DefaultConfigurationStore(); MutableConfiguration facNode = new MutableConfiguration("facility"); facNode.Attributes["id"] = "slow"; facNode.Attributes["type"] = "Castle.Windsor.Tests.Facilities.SlowlyInitFacility, Castle.Windsor.Tests"; configurationStore.AddFacilityConfiguration("slow", facNode); MutableConfiguration compNode = new MutableConfiguration("component"); compNode.Attributes["id"] = "a"; compNode.Attributes["type"] = "Castle.Windsor.Tests.Components.CalculatorService, Castle.Windsor.Tests"; configurationStore.AddComponentConfiguration("a", compNode); AsyncInitializationContainer container = new AsyncInitializationContainer(configurationStore); Assert.AreEqual(1, container.Kernel.GraphNodes.Length); Assert.AreEqual(1, container.Kernel.GraphNodes.Length); CalculatorService service = (CalculatorService) container[typeof(CalculatorService)]; Assert.IsNotNull(service); service = (CalculatorService) container[typeof(CalculatorService)]; }
static void Main(string[] args) { //var logger = IoCUtil.Resolve<ILoger>(); //var messageSender = IoCUtil.Resolve<IMessageSender>(); //logger.WriteLog("Log Text"); //messageSender.SendMessage("Message Text"); config = new DefaultConfigurationStore(); container = new WindsorContainer(); var installer = new TestInstaller(); installer.Install(container, config); var resolver = new WindsorDependencyResolver(container.Kernel); var logs = resolver.GetServices(typeof(ILoger)); foreach (var log in logs) { var kk = log; Console.WriteLine(log); } resolver.BeginScope(); Console.ReadLine(); }
public void ProperDeserialization() { var store = new DefaultConfigurationStore(); var interpreter = new XmlInterpreter(new ConfigResource()); IKernel kernel = new DefaultKernel(); interpreter.ProcessResource(interpreter.Source, store, kernel); Assert.AreEqual(2, store.GetFacilities().Length); Assert.AreEqual(4, store.GetComponents().Length); var config = store.GetFacilityConfiguration(typeof(NoopFacility).FullName); var childItem = config.Children["item"]; Assert.IsNotNull(childItem); Assert.AreEqual("value", childItem.Value); config = store.GetFacilityConfiguration(typeof(Noop2Facility).FullName); Assert.IsNotNull(config); Assert.AreEqual("value within CDATA section", config.Value); config = store.GetComponentConfiguration("testidcomponent1"); childItem = config.Children["item"]; Assert.IsNotNull(childItem); Assert.AreEqual("value1", childItem.Value); config = store.GetComponentConfiguration("testidcomponent2"); childItem = config.Children["item"]; Assert.IsNotNull(childItem); Assert.AreEqual("value2", childItem.Value); }
public void SetUp() { var configurationStore = new DefaultConfigurationStore(); var resource = new AssemblyResource("Castle.Facilities.NHibernateIntegration.Tests/Issues/Facilities117/facility.xml"); var xmlInterpreter = new XmlInterpreter(resource); xmlInterpreter.ProcessResource(resource, configurationStore); facilityCfg = configurationStore.GetFacilityConfiguration("nhibernatefacility").Children["factory"]; }
public void MissingManifestResourceConfiguration() { var store = new DefaultConfigurationStore(); var source = new AssemblyResource("assembly://Castle.Windsor.Tests/missing_config.xml"); IKernel kernel = new DefaultKernel(); Assert.Throws <ConfigurationProcessingException>(() => new XmlInterpreter(source).ProcessResource(source, store, kernel)); }
public override void OnSetUp() { var configurationStore = new DefaultConfigurationStore(); var resource = new AssemblyResource("Castle.Facilities.NHibernateIntegration.Tests/Issues/Facilities116/facility.xml"); var xmlInterpreter = new XmlInterpreter(resource); xmlInterpreter.ProcessResource(resource, configurationStore); configuration = configurationStore.GetFacilityConfiguration("nhibernatefacility").Children["factory"]; configurationBuilder = new PersistentConfigurationBuilder(); }
private static IWindsorContainer CreateWindsorContainer() { var ioc = new MainIOC(); IWindsorContainer container = new WindsorContainer(); IConfigurationStore configurationStore = new DefaultConfigurationStore(); ioc.Install(container, configurationStore); return(container); }
public void InvalidUrl_throws() { var configStore = new DefaultConfigurationStore(); var configuration = new MutableConfiguration("facility"); configuration.Attributes.Add("type", typeof(SolrNetFacility).FullName); configuration.CreateChild("solrURL", "123"); configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration); new WindsorContainer(configStore); }
public override void OnSetUp() { var configurationStore = new DefaultConfigurationStore(); var resource = new AssemblyResource("Castle.Facilities.NHibernateIntegration.Tests/Issues/Facilities116/facility.xml"); var xmlInterpreter = new XmlInterpreter(resource); xmlInterpreter.ProcessResource(resource, configurationStore, new DefaultKernel()); configuration = configurationStore.GetFacilityConfiguration(typeof(NHibernateFacility).FullName).Children["factory"]; configurationBuilder = new PersistentConfigurationBuilder(); }
public void CanLoadModuleImplicit() { var container = new WindsorContainer(); var defaultConfigurationStore = new DefaultConfigurationStore(); FromAssembly.Containing <RemoteEngineContextFactory>().Install(container, defaultConfigurationStore); AssertResolvable(container); }
public void JsonInterpreter_test() { IConfigurationStore store = new DefaultConfigurationStore(); string uri = "SqlMap.config.Json"; IResource resource = ResourceLoaderRegistry.GetResource(uri); IConfigurationInterpreter interpreter = new JsonInterpreter(resource); interpreter.ProcessResource(store); }
public void InvalidProtocol_throws() { var configStore = new DefaultConfigurationStore(); var configuration = new MutableConfiguration("facility"); configuration.Attribute("type", typeof(SolrNetFacility).AssemblyQualifiedName); configuration.CreateChild("solrURL", "ftp://localhost"); configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration); Assert.Throws <FacilityException>(() => new WindsorContainer(configStore)); }
public void Test_XmlConfigurationInterpreter_via_FilePath() { string uri = "SqlMap_Test_Configure.config"; IConfigurationStore store = new DefaultConfigurationStore(); IConfigurationInterpreter interpreter = new XmlConfigurationInterpreter(uri); interpreter.ProcessResource(store); CheckResource(store); }
public void InvalidProtocol_throws() { var configStore = new DefaultConfigurationStore(); var configuration = new MutableConfiguration("facility"); configuration.CreateChild("solrURL", "ftp://localhost"); configStore.AddFacilityConfiguration("solr", configuration); var container = new WindsorContainer(configStore); container.AddFacility <SolrNetFacility>("solr"); }
public void CanLoadModuleExplicit() { var container = new WindsorContainer(); var defaultConfigurationStore = new DefaultConfigurationStore(); var ogDotNetModule = new OGDotNetModule(); ogDotNetModule.Install(container, defaultConfigurationStore); AssertResolvable(container); }
public void Init() { DefaultConfigurationStore store = new DefaultConfigurationStore(); XmlInterpreter interpreter = new XmlInterpreter(new ConfigResource()); interpreter.ProcessResource(interpreter.Source, store); _container = new PestControlContainer(interpreter); _model = (PestControlModel)_container["pestcontrolModel"]; _engine = (PrevalenceEngine)_container["prevalenceengine"]; }
public void CorrectConfigurationMapping() { DefaultConfigurationStore store = new DefaultConfigurationStore(); XmlInterpreter interpreter = new XmlInterpreter("sample_config.xml"); interpreter.ProcessResource(interpreter.Source, store); WindsorContainer container = new WindsorContainer(store); container.AddFacility("testidengine", new DummyFacility()); }
public void Test_XmlConfigurationInterpreter_via_FilePath_WithoutProtocol() { string uri = "SqlMap_Test_Configure.config"; IConfigurationStore store = new DefaultConfigurationStore(); IConfigurationInterpreter interpreter = new XmlConfigurationInterpreter( ResourceLoaderRegistry.GetResource(uri)); interpreter.ProcessResource(store); CheckResource(store); }
public void Test_XmlConfigurationInterpreter_via_AssemblyUri() { string uri = "assembly://MyBatis.DataMapper.SqlClient.Test/bin.Debug/SqlMap_Test_Configure.config"; IConfigurationStore store = new DefaultConfigurationStore(); IConfigurationInterpreter interpreter = new XmlConfigurationInterpreter( ResourceLoaderRegistry.GetResource(uri)); interpreter.ProcessResource(store); CheckResource(store); }
public void CorrectConfigurationMapping() { var store = new DefaultConfigurationStore(); var interpreter = new XmlInterpreter(Xml.Embedded("sample_config.xml")); IKernel kernel = new DefaultKernel(); interpreter.ProcessResource(interpreter.Source, store, kernel); var container = new WindsorContainer(store); var facility = container.Kernel.GetFacilities().OfType <HiperFacility>().Single(); Assert.IsTrue(facility.Initialized); }
public void ComponentIdGetsLoadedFromTheParsedConfiguration() { var store = new DefaultConfigurationStore(); var interpreter = new XmlInterpreter(Xml.Embedded("sample_config_with_spaces.xml")); IKernel kernel = new DefaultKernel(); interpreter.ProcessResource(interpreter.Source, store, kernel); var container = new WindsorContainer(store); var handler = container.Kernel.GetHandler(typeof(ICalcService)); Assert.AreEqual(Core.LifestyleType.Transient, handler.ComponentModel.LifestyleType); }
public void Should_Error_if_Missing_HyperV_Password_Setting() { string expectedMessage = "Missing Configuration Setting: HYPERV_PWD"; string oldConfig = RemoveConfigNode(configPath, "HYPERV_PWD"); DefaultConfigurationStore store = DefaultConfigurationStore.Current; IVMData hyperV = new HyperVData(); ValidateLaunch canLaunch = new ValidateLaunch(store, hyperV); ConfigurationException ex = Assert.Throws <ConfigurationErrorsException>(() => canLaunch.VerifyLaunchConditions()); RestoreConfiguration(configPath, oldConfig); Assert.Equal(expectedMessage, ex.Message); }
public void XmlProcessorTest() { using (XmlTextReader reader = new XmlTextReader("SqlMap_Test_Configure.config")) { IConfigurationStore store = new DefaultConfigurationStore(); using (XmlConfigProcessor processor = new XmlConfigProcessor()) { processor.Process(reader, store); CheckResource(store); } } }
public void Ping_Query() { var configStore = new DefaultConfigurationStore(); var configuration = new MutableConfiguration("facility"); configuration.Attribute("type", typeof(SolrNetFacility).AssemblyQualifiedName); configuration.CreateChild("solrURL", "http://localhost:8983/solr"); configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration); var container = new WindsorContainer(configStore); var solr = container.Resolve <ISolrOperations <CastleFixture.Document> >(); solr.Ping(); Console.WriteLine(solr.Query(SolrQuery.All).Count); }
public void ExceptionBeingSaved() { IConfigurationStore configurationStore = new DefaultConfigurationStore(); MutableConfiguration facNode = new MutableConfiguration("facility"); facNode.Attributes["id"] = "slow"; facNode.Attributes["type"] = "Castle.Windsor.Tests.Facilities.IDontExist, Castle.Windsor.Tests"; configurationStore.AddFacilityConfiguration("slow", facNode); AsyncInitializationContainer container = new AsyncInitializationContainer(configurationStore); Assert.AreEqual(1, container.Kernel.GraphNodes.Length); }
public void Ping_Query() { var configStore = new DefaultConfigurationStore(); var configuration = new MutableConfiguration("facility"); configuration.CreateChild("solrURL", "http://localhost:8983/solr"); configStore.AddFacilityConfiguration("solr", configuration); var container = new WindsorContainer(configStore); container.AddFacility <SolrNetFacility>("solr"); var solr = container.Resolve <ISolrOperations <Document> >(); solr.Ping(); Console.WriteLine(solr.Query(SolrQuery.All).Count); }
public void Test_DefaultModelBuilder() { string uri = "SqlMap_Test_Configure.config"; IConfigurationStore store = new DefaultConfigurationStore(); IConfigurationInterpreter interpreter = new XmlConfigurationInterpreter(uri); interpreter.ProcessResource(store); //Console.WriteLine(store.ToString()); IModelStore modelStore = new DefaultModelStore(); IModelBuilder builder = new DefaultModelBuilder(modelStore); builder.BuildModel(null, store); CheckModelStore(modelStore); }