public void PipelineBuilder_BuildFromConfiguration_AssemblyServices_MultiAvailable() { var element = new ElementOptions() { BuilderName = "RequiredService" }; // Create configuration object. PipelineOptions opts = new PipelineOptions(); opts.Elements = new List <ElementOptions> { element }; var service = new RequiredServiceElementBuilder.EmptyService(); var httpClient = new Mock <HttpClient>(); var updateService = new DataUpdateService( new Mock <ILogger <DataUpdateService> >().Object, httpClient.Object); var services = new FiftyOneServiceProvider(); services.AddService(service); services.AddService(updateService); // Pass the configuration to the builder to create the pipeline. var pipeline = new PipelineBuilder(_loggerFactory, services) .BuildFromConfiguration(opts); Assert.IsNotNull(pipeline.GetElement <RequiredServiceElement>().LoggerFactory); Assert.IsNotNull(pipeline.GetElement <RequiredServiceElement>().Service); Assert.AreEqual(service, pipeline.GetElement <RequiredServiceElement>().Service); Assert.IsNotNull(pipeline.GetElement <RequiredServiceElement>().UpdateService); Assert.AreEqual(updateService, pipeline.GetElement <RequiredServiceElement>().UpdateService); }
public void PipelineBuilder_BuildFromConfiguration_AssemblyServices_NotAvailable() { var element = new ElementOptions() { BuilderName = "RequiredService" }; // Create configuration object. PipelineOptions opts = new PipelineOptions(); opts.Elements = new List <ElementOptions> { element }; // Pass the configuration to the builder to create the pipeline. var pipeline = new PipelineBuilder(_loggerFactory, new FiftyOneServiceProvider()) .BuildFromConfiguration(opts); Assert.IsNotNull(pipeline.GetElement <RequiredServiceElement>().LoggerFactory); Assert.IsNull(pipeline.GetElement <RequiredServiceElement>().Service); Assert.IsNull(pipeline.GetElement <RequiredServiceElement>().UpdateService); }
public void PipelineBuilder_BuildFromConfiguration_ServiceCollection() { var element = new ElementOptions() { BuilderName = "MultiplyByElementBuilder" }; element.BuildParameters.Add("multiple", "3"); // Create the configuration object. PipelineOptions opts = new PipelineOptions(); opts.Elements = new List <ElementOptions> { element }; Mock <IServiceProvider> services = new Mock <IServiceProvider>(); services.Setup(s => s.GetService(typeof(MultiplyByElementBuilder))) .Returns(new MultiplyByElementBuilder()); // Pass the configuration to the builder to create the pipeline. var pipeline = new PipelineBuilder(_loggerFactory, services.Object) .BuildFromConfiguration(opts); // Get the element var multiplyByElement = pipeline.GetElement <MultiplyByElement>(); // Create, populate and process flow data. using (var flowData = pipeline.CreateFlowData()) { flowData .AddEvidence(multiplyByElement.EvidenceKeys[0], 25) .Process(); // Get the results and verify them. var multiplyByData = flowData.GetFromElement(multiplyByElement); Assert.AreEqual(75, multiplyByData.Result); } }