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)]; }
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 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 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 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 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.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 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 TransientComponents() { 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 AnotherService " + " " + " 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("interceptor1", typeof(CastleSimpleInterceptor)); container.AddComponent("comp1", typeof(SimpleService)); container.AddComponent("comp2", typeof(IAnotherService), typeof(AnotherService)); for (int i = 1; i < 10000; i++) { LoggerInterceptor.Messages.Length = 0; IAnotherService service = container[typeof(IAnotherService)] as IAnotherService; service.Name = "hammett"; service.StartWork(); Assert.AreEqual("Enter set_Name\r\nEnter StartWork\r\n", LoggerInterceptor.Messages.ToString()); CastleSimpleInterceptor interceptor = container[typeof(CastleSimpleInterceptor)] as CastleSimpleInterceptor; Assert.AreEqual(2 * i, interceptor.Executions); } }