示例#1
0
        public async Task Basic()
        {
            PipelineResult <Wrapper <int> > result = await PipelineGenerator.CreateBuilder().UseSampleCommandInvoker(new CountCommand().Build(),
                                                                                                                     new string[] { "count" });

            ResultAssert.OkWithZero(result);
        }
        public async Task Basic()
        {
            PipelineResult <Wrapper <int> > result = await PipelineGenerator.CreateBuilder().UseSampleCommandInvoker(
                new DebugCommand().Build(),
                new string[] { "debug" },
                after: context =>
            {
                Assert.IsFalse(string.IsNullOrEmpty(context.Services.GetService <IConsole>().Out.ToString()));
                return(Task.CompletedTask);
            });

            ResultAssert.OkWithZero(result);
        }
        public async Task Basic()
        {
            Logger        logger    = new Logger();
            TestWorkspace workspace = new TestWorkspace(logger.CreateScope("main", LogLevel.Debug));
            PipelineResult <Wrapper <int> > result = await PipelineGenerator.CreateBuilder().UseSampleCommandInvoker(new InitCommand().Build(),
                                                                                                                     new string[] { "init" },
                                                                                                                     workspace: workspace,
                                                                                                                     after: context => Task.FromResult <Wrapper <int> >(0));

            logger.AssertInvoked(nameof(IWorkspace.Initialize));

            ResultAssert.OkWithZero(result);
        }
        public async Task Directory()
        {
            Logger        logger    = new Logger();
            TestWorkspace workspace = new TestWorkspace(logger.CreateScope("main", LogLevel.Debug),
                                                        onCreate: (name, tem, callback) => Task.FromResult <IWorkItem?>(new TestWorkItem("")));

            PipelineResult <Wrapper <int> > result = await PipelineGenerator.CreateBuilder().UseSampleCommandInvoker(
                new NowCommand().Build(),
                new string[] { "now", "--", "type=d", "target=a" },
                workspace: workspace);

            logger.AssertInvoked(nameof(IWorkspace.Create));

            ResultAssert.OkWithZero(result);
        }
        public async Task Basic()
        {
            Logger        logger    = new Logger();
            TestWorkspace workspace = new TestWorkspace(logger.CreateScope("main", LogLevel.Debug));
            PipelineResult <Wrapper <int> > result = await PipelineGenerator.CreateBuilder().UseSampleCommandInvoker(
                new NewCommand().Build(),
                new string[] { "new", "c", "a" },
                workspace: workspace,
                before: async context =>
            {
                _ = await PipelineGenerator.InitializeWorkspace(context);
                await context.Services.GetWorkspace().Templates.SetValue("c", FileTemplates.C);
            });

            logger.AssertInvoked(nameof(IWorkspace.Create));
            ResultAssert.OkWithZero(result);
        }
        public async Task Basic()
        {
            Logger        logger    = new Logger();
            TestWorkspace workspace = new TestWorkspace(logger.CreateScope("main", LogLevel.Debug),
                                                        onExecute: (item, op, call, watcher, logger) => Task.FromResult(new PipelineResult <Wrapper <bool> >(true, null, Array.Empty <LogItem>())));
            PipelineResult <Wrapper <int> > result = await PipelineGenerator.CreateBuilder().UseSampleCommandInvoker(
                new RunCommand().Build(),
                new string[] { "hello", "--", "name=a" },
                workspace: workspace,
                before: async context =>
            {
                _ = await PipelineGenerator.InitializeWorkspace(context);
                await context.Services.GetWorkspace().Operations.SetValue("hello", CodeRunner.Managements.FSBased.Templates.OperationsSpaceTemplate.Hello);
            });

            logger.AssertInvoked(nameof(IWorkspace.Execute));

            ResultAssert.OkWithZero(result);
        }