示例#1
0
        public async Task TestConnector()
        {
            var logger = new TestOutputLogger("Step Logger", TestOutputHelper);

            var absolutePath = PluginLoadContext.GetAbsolutePath(RelativePath);

            var assembly = PluginLoadContext.LoadPlugin(
                absolutePath,
                logger
                );

            assembly.ShouldBeSuccessful();

            var stepTypes = assembly.Value.GetTypes()
                            .Where(x => typeof(IStep).IsAssignableFrom(x))
                            .ToList();

            foreach (var type in stepTypes)
            {
                TestOutputHelper.WriteLine(type.Name);
            }

            var stepFactoryStore = StepFactoryStore.Create(
                new ConnectorData(ConnectorSettings.DefaultForAssembly(assembly.Value), assembly.Value)
                );

            var injectedContextsResult = stepFactoryStore.TryGetInjectedContexts(
                new SCLSettings(
                    Entity.Create(
                        new List <(EntityPropertyKey key, object?value)>()
            {
                (new EntityPropertyKey(new[] { "connectors", "example", "colorSource" }),
                 "Red")
            }
                        )
                    )
                );

            injectedContextsResult.ShouldBeSuccessful();

            var externalContext = ExternalContext.Default with
            {
                InjectedContexts = injectedContextsResult.Value
            };

            var runner = new SCLRunner(
                SCLSettings.EmptySettings,
                logger,
                stepFactoryStore,
                externalContext
                );

            var r = await
                    runner.RunSequenceFromTextAsync(
                "Log (GetTestString)",
                new Dictionary <string, object>(),
                CancellationToken.None
                );

            r.ShouldBeSuccessful();
        }
    }