Esempio n. 1
0
        public async Task RunSCLFromFile(string path)
        {
            var scl = await File.ReadAllTextAsync(path);

            TestOutputHelper.WriteLine(scl);

            var sfs = StepFactoryStore.Create();

            var stepResult = SCLParsing.TryParseStep(scl)
                             .Bind(x => x.TryFreeze(TypeReference.Any.Instance, sfs));

            if (stepResult.IsFailure)
            {
                throw new XunitException(
                          string.Join(
                              ", ",
                              stepResult.Error.GetAllErrors()
                              .Select(x => x.Message + " " + x.Location.AsString())
                              )
                          );
            }

            var monad = new StateMonad(
                TestOutputHelper.BuildLogger(),
                SCLSettings.EmptySettings,
                sfs,
                ExternalContext.Default,
                new Dictionary <string, object>()
                );

            var r = await stepResult.Value.Run <Unit>(monad, CancellationToken.None);

            r.ShouldBeSuccessful();
        }
Esempio n. 2
0
        public async Task RunSCLSequence()
        {
            const string scl = @"
- <root> = 'Documentation'
- <docs> = GenerateDocumentation

# Create a directory for each connector
- <docs>
  | ArrayDistinct (From <Entity> 'Directory')
  | ForEach (
      CreateDirectory (PathCombine [<root>, (From <Entity> 'Directory')])
    )

# Export all steps to .\<root>\ConnectorName\StepName.md
- <docs>
  | Foreach (
      FileWrite
        (From <Entity> 'FileText')
        (PathCombine [<root>, (From <Entity> 'Directory'), (From <Entity> 'FileName')])
    )

";

            var logger =
                TestOutputHelper.BuildLogger(new LoggingConfig()
            {
                LogLevel = LogLevel.Information
            });

            var sfs = StepFactoryStore.Create();

            var runner = new SCLRunner(
                SCLSettings.EmptySettings,
                logger,
                sfs,
                ExternalContext.Default
                );

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

            r.ShouldBeSuccessful();
        }