Exemplo n.º 1
0
        public Task CommandAppAsyncTest(string[] args,
                                        string commandName,
                                        Action <CommandConfiguration <Models.BuildOptions> > configure,
                                        Models.BuildOptions expectedOptions)
        {
            var configuration = new ApplicationConfiguration <Models.Options>();

            configuration
            .Command <Models.BuildOptions>(commandName, cfg =>
            {
                configure(cfg);
                cfg.OnExecuteAsync(opt =>
                {
                    opt.ShouldBe(expectedOptions);
                    return(Task.CompletedTask);
                });
            })
            .PositionArgument(arg => arg.Map.ToProperty(o => o.Project))
            .OnExecuteAsync(_ =>
            {
                false.ShouldBeTrue("App handler called, shouldn't been");
                return(Task.CompletedTask);
            });
            return(RuntimeCommandBuilder.Build(configuration, args, out var options)
                   .InvokeAsync(options, CancellationToken.None));
        }
Exemplo n.º 2
0
        public void CommandAppTest(string[] args,
                                   string commandName,
                                   Action <CommandConfiguration <Models.BuildOptions> > configure,
                                   Models.BuildOptions expectedOptions)
        {
            var configuration = new ApplicationConfiguration <Models.Options>();

            configuration
            .Command <Models.BuildOptions>(commandName, cfg =>
            {
                configure(cfg);
                cfg.OnExecute(opt => opt.ShouldBe(expectedOptions));
            })
            .PositionArgument(arg => arg.Map.ToProperty(o => o.Project))
            .OnExecute(_ => false.ShouldBeTrue("App handler called, shouldn't been"));
            RuntimeCommandBuilder.Build(configuration, args, out var options).Invoke(options);
        }