public async Task Delete()
        {
            TestWorkspace workspace = new TestWorkspace();
            PipelineResult <Wrapper <int> > result = await Utils.UseSampleCommandInvoker(workspace,
                                                                                         new InitCommand().Build(),
                                                                                         new string[] { "init", "--delete" },
                                                                                         after : context => Task.FromResult <Wrapper <int> >(0));

            workspace.AssertInvoked(nameof(IWorkspace.Clear));
            Assert.IsTrue(result.IsOk);
            Assert.AreEqual <int>(0, result.Result !);
        }
        public async Task File()
        {
            TestWorkspace workspace = new TestWorkspace(
                onCreate: (name, tem, callback) => Task.FromResult <IWorkItem?>(new TestWorkItem()));

            PipelineResult <Wrapper <int> > result = await Utils.UseSampleCommandInvoker(workspace,
                                                                                         new NowCommand().Build(),
                                                                                         new string[] { "now", "--", "type=f", "target=a.c" },
                                                                                         before : Utils.InitializeWorkspace,
                                                                                         after : context => Task.FromResult <Wrapper <int> >(0));

            workspace.AssertInvoked(nameof(IWorkspace.Create));
            Assert.IsTrue(result.IsOk);
            Assert.AreEqual <int>(0, result.Result !);
        }
        public async Task Basic()
        {
            TestWorkspace workspace = new TestWorkspace(onExecute: (item, op, call, watcher, logger) => Task.FromResult(new PipelineResult <Wrapper <bool> >(true, null, Array.Empty <LogItem>())));
            PipelineResult <Wrapper <int> > result = await Utils.UseSampleCommandInvoker(workspace,
                                                                                         new RunCommand().Build(),
                                                                                         new string[] { "hello", "--", "name=a" },
                                                                                         before : async context =>
            {
                _ = await Utils.InitializeWorkspace(context);
                await context.Services.GetWorkspace().Operations.SetValue("hello", CodeRunner.Managements.FSBased.Templates.OperationsSpaceTemplate.Hello);
                return(0);
            },
                                                                                         after : context => Task.FromResult <Wrapper <int> >(0));

            workspace.AssertInvoked(nameof(IWorkspace.Execute));
            Assert.IsTrue(result.IsOk);
            Assert.AreEqual <int>(0, result.Result !);
        }
Example #4
0
        public async Task Basic()
        {
            TestWorkspace workspace = new TestWorkspace();
            PipelineResult <Wrapper <int> > result = await Utils.UseSampleCommandInvoker(workspace,
                                                                                         new NewCommand().Build(),
                                                                                         new string[] { "new", "c", "a" },
                                                                                         before : async context =>
            {
                _ = await Utils.InitializeWorkspace(context);
                await context.Services.GetWorkspace().Templates.SetValue("c", FileTemplates.C);
                return(0);
            },
                                                                                         after : context =>
            {
                workspace.AssertInvoked(nameof(IWorkspace.Create));
                return(Task.FromResult <Wrapper <int> >(0));
            });

            Assert.IsTrue(result.IsOk);
            Assert.AreEqual <int>(0, result.Result !);
        }