public async Task Empty()
        {
            var clizer = new Clizer();
            var result = await clizer.Execute(Array.Empty <string>());

            Assert.Equal(ClizerExitCode.SUCCESS, result);
        }
        public async Task Ignored_Property()
        {
            var args = new List <string>()
            {
                "--ignore"
            };

            var clizer = new Clizer();

            clizer.Configure((config) => config.RegisterCommands <PropertyBindingCmd>());
            await Assert.ThrowsAnyAsync <ClizerException>(() => clizer.Execute(args.ToArray()));
        }
        public async Task With_Root_And_Sub_Commands(string rawArgs)
        {
            var args = rawArgs.Split(';');

            var clizer = new Clizer()
                         .Configure((config) => config
                                    .RegisterCommands(GetType().Assembly));

            var result = await clizer.Execute(args);

            Assert.Equal(ClizerExitCode.SUCCESS, result);
        }
Example #4
0
        public async Task Injection()
        {
            var pathResolver = new InMemoryFileAccessor <ClizerDictionary>(new ClizerDictionary());

            var clizer = new Clizer()
                         .Configure((config) => config
                                    .EnableMapping(pathResolver)
                                    .RegisterCommands <MappingCommand>());

            var result = await clizer.Execute(Array.Empty <string>());

            Assert.Equal(ClizerExitCode.SUCCESS, result);
        }
        public async Task With_Shortcuts()
        {
            var args = new List <string>()
            {
                "-n:1",
                "-f"
            };

            var clizer = new Clizer();

            clizer.Configure((config) => config.RegisterCommands <PropertyBindingCmd>());
            var result = await clizer.Execute(args.ToArray());

            Assert.Equal(ClizerExitCode.SUCCESS, result);
        }
        public async Task Correct_Binding_Property()
        {
            var args = new List <string>()
            {
                "--number:1",
                "--force"
            };

            var clizer = new Clizer();

            clizer.Configure((config) => config.RegisterCommands <PropertyBindingCmd>());
            var result = await clizer.Execute(args.ToArray());

            Assert.Equal(ClizerExitCode.SUCCESS, result);
        }
Example #7
0
        public async Task Call_Help(string arg)
        {
            var args = new List <string>()
            {
                arg
            };

            var clizer = new Clizer()
                         .Configure(config => config
                                    .RegisterCommands(GetType().Assembly)
                                    .EnableHelp());

            var result = await clizer.Execute(args.ToArray());

            Assert.NotEqual(ClizerExitCode.ERROR, result);
        }
Example #8
0
        public async Task Inject_Config()
        {
            var fileAccessor = new InMemoryFileAccessor <TestUserConfiguration>(
                new TestUserConfiguration()
            {
                Value = 99
            });

            var clizer = new Clizer()
                         .Configure((config) => config
                                    .EnableConfig("config", fileAccessor)
                                    .RegisterCommands <UserConfigCommand>());

            var result = await clizer.Execute(Array.Empty <string>());

            Assert.Equal(ClizerExitCode.SUCCESS, result);
        }
Example #9
0
        public async Task Runtime()
        {
            var args = new List <string>()
            {
                "ut"
            };

            var aliases      = "ut = unit test al \r\n al = aliases";
            var fileAccessor = new InMemoryFileAccessor <string>(aliases);
            var clizer       = new Clizer()
                               .Configure(config => config
                                          .EnableAliases(fileAccessor)
                                          .RegisterCommands(GetType().Assembly));

            var result = await clizer.Execute(args.ToArray());

            Assert.Equal(ClizerExitCode.SUCCESS, result);
        }
Example #10
0
        public async Task Invalid_Range()
        {
            var args = new List <string>()
            {
                "add",
                "--second:0"
            };

            var clizer = new Clizer();

            clizer.Configure((config) => config

                             .HandleException((ex) => throw ex)
                             .RegisterCommands(GetType().Assembly)
                             );

            await Assert.ThrowsAsync <ValidationException>(() => clizer.Execute(args.ToArray()));
        }
Example #11
0
        public async Task Create_and_Inject_Config()
        {
            var file   = "smitty_werben_jagger_man_jensen.json";
            var exists = File.Exists(file);

            if (exists)
            {
                File.Delete(file);
            }

            var clizer = new Clizer()
                         .Configure((config) => config
                                    .EnableConfig <TestUserConfiguration>("config", "smitty_werben_jagger_man_jensen.json")
                                    .RegisterCommands <UserConfigCommand>());

            var result = await clizer.Execute(Array.Empty <string>());

            Assert.Equal(ClizerExitCode.SUCCESS, result);
        }