示例#1
0
 public void Init()
 {
     CLILogsTest.SurchargeLogs();
     Option  = new Options.AccountOptions();
     Config  = new DefaultRunConfiguration(ConfigType.Task, CommandApi.List);
     Convert = new OptionConverter(new UnitTestJsonDeserializer());
 }
示例#2
0
        public void AllOptionsCheckNoArg()
        {
            string[] argv = new string[] { "all" };
            DefaultRunConfiguration confset = Parser.Parse(argv) as DefaultRunConfiguration;

            Assert.AreEqual(confset.Type, ConfigType.All);
            Assert.AreEqual(confset.Command, CommandApi.List);
        }
示例#3
0
        public void ListPoolCheckTestParsArg()
        {
            string poolUuid = "PoolUUID";
            string name     = "NAME";
            string tags     = "TAG1,TAG2";

            string[]          argv = null;
            var               commandLineParser = new CommandLine.Parser();
            CommandLineParser parser            = new CommandLineParser(new OptionConverter(new JsonDeserializer()), commandLineParser, new ParserUsage(), new VerbFormater());
            IConfiguration    iConfSet          = null;

            argv     = new string[] { "pool", "list" };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is DefaultRunConfiguration))
            {
                throw new Exception("return value is not DefaultRunConfiguration ");
            }

            DefaultRunConfiguration confset = (DefaultRunConfiguration)iConfSet;

            Assert.AreEqual(confset.Type, ConfigType.Pool);
            Assert.AreEqual(confset.Command, CommandApi.List);

            argv     = new string[] { "pool", "list", "--name", name, "--id", poolUuid, "--tags", tags };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is DefaultRunConfiguration))
            {
                throw new Exception("return value is not DefaultRunConfiguration ");
            }

            confset = (DefaultRunConfiguration)iConfSet;
            Assert.AreEqual(confset.Type, ConfigType.Pool);
            Assert.AreEqual(confset.Command, CommandApi.List);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Id, poolUuid);

            argv     = new string[] { "pool", "list", "-n", name, "-i", poolUuid, "-t", tags };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is DefaultRunConfiguration))
            {
                throw new Exception("return value is not DefaultRunConfiguration ");
            }

            confset = (DefaultRunConfiguration)iConfSet;
            Assert.AreEqual(confset.Type, ConfigType.Pool);
            Assert.AreEqual(confset.Command, CommandApi.List);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Id, poolUuid);
            commandLineParser.Dispose();
        }
示例#4
0
        public void AllOptionsCheckAbort()
        {
            string[] argv = new string[] { "all", "--abort" };
            DefaultRunConfiguration confset = Parser.Parse(argv) as DefaultRunConfiguration;

            Assert.AreEqual(confset.Type, ConfigType.All);
            Assert.AreEqual(confset.Command, CommandApi.Abort);

            argv    = new string[] { "all", "-a" };
            confset = Parser.Parse(argv) as DefaultRunConfiguration;
            Assert.AreEqual(confset.Type, ConfigType.All);
            Assert.AreEqual(confset.Command, CommandApi.Abort);
        }
示例#5
0
        public void AllOptionsCheckDelete()
        {
            string[] argv = new string[] { "all", "--delete" };

            DefaultRunConfiguration confset = Parser.Parse(argv) as DefaultRunConfiguration;

            Assert.AreEqual(confset.Type, ConfigType.All);
            Assert.AreEqual(confset.Command, CommandApi.Delete);

            argv    = new string[] { "all", "-d" };
            confset = Parser.Parse(argv) as DefaultRunConfiguration;
            Assert.AreEqual(confset.Type, ConfigType.All);
            Assert.AreEqual(confset.Command, CommandApi.Delete);
        }
示例#6
0
        public async Task TestForCommandAll()
        {
            FakeHTTP.ReturnMessage = HttpTaskObject.TasksListBodiesWithPaging;
            ConfigType type    = ConfigType.All;
            CommandApi command = CommandApi.List;

            Dictionary <string, ICommandLauncher> dict = new Dictionary <string, ICommandLauncher>()
            {
                { "first", LaunchFactory.CreateLauncher(ConfigType.Task, command) },
                { "second", LaunchFactory.CreateLauncher(ConfigType.Pool, command) },
            };

            var allConfig = new DefaultRunConfiguration(type, command);
            var all       = new CommandAll(dict);
            await all.RunAndPrintCommandAsync(allConfig, FalsePrinter);
        }
示例#7
0
        public void CheckTaskCheckNotCreateConfigurationIsAlwayValid()
        {
            IConfiguration config = new AccountConfiguration(ConfigType.Account, CommandApi.Info)
            {
            };

            Assert.IsTrue(CommandLineParser.CheckTask(config));
            config = new DefaultRunConfiguration(ConfigType.Pool, CommandApi.Info)
            {
            };
            Assert.IsTrue(CommandLineParser.CheckTask(config));
            config = new DefaultRunConfiguration(ConfigType.Pool, CommandApi.Info)
            {
                Type = ConfigType.Pool
            };
            Assert.IsTrue(CommandLineParser.CheckTask(config));
        }
示例#8
0
        public void CheckJobAlwayValid()
        {
            IConfiguration config = new AccountConfiguration(ConfigType.Account, CommandApi.Info)
            {
            };

            Assert.IsTrue(CommandLineParser.CheckJob(config));
            config = new DefaultRunConfiguration(ConfigType.Job, CommandApi.List)
            {
            };
            Assert.IsTrue(CommandLineParser.CheckJob(config));
            config = new DefaultRunConfiguration(ConfigType.Job, CommandApi.List)
            {
                Type = ConfigType.Task
            };
            Assert.IsTrue(CommandLineParser.CheckJob(config));
        }
示例#9
0
        public void PoolBasicSubverbCanHaveAllTheBasicFlags(string subverb, CommandApi commandEnum)
        {
            string poolUuid = "PoolUUID";
            string name     = "NAME";
            string tags     = "TAG1,TAG2";

            string[]          argv = null;
            var               commandLineParser = new CommandLine.Parser();
            CommandLineParser parser            = new CommandLineParser(new OptionConverter(new JsonDeserializer()), commandLineParser, new ParserUsage(), new VerbFormater());
            IConfiguration    iConfSet          = null;

            argv     = new string[] { "pool", subverb, "--name", name, "--id", poolUuid, "--tags", tags };
            iConfSet = parser.Parse(argv);
            if (!(iConfSet is DefaultRunConfiguration))
            {
                throw new Exception("return value is not DefaultRunConfiguration ");
            }

            DefaultRunConfiguration confset = (DefaultRunConfiguration)iConfSet;

            Assert.AreEqual(confset.Type, ConfigType.Pool);
            Assert.AreEqual(confset.Command, commandEnum);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Id, poolUuid);
            Assert.IsFalse(confset.TagsIntersect);
            CollectionAssert.Contains(confset.Tags, tags);

            argv     = new string[] { "pool", subverb, "--name", name, "--id", poolUuid, "--exclusive-tags", tags };
            iConfSet = parser.Parse(argv);
            if (!(iConfSet is DefaultRunConfiguration))
            {
                throw new Exception("return value is not DefaultRunConfiguration ");
            }

            confset = (DefaultRunConfiguration)iConfSet;
            Assert.AreEqual(confset.Type, ConfigType.Pool);
            Assert.AreEqual(confset.Command, commandEnum);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Id, poolUuid);
            Assert.IsTrue(confset.TagsIntersect);
            CollectionAssert.Contains(confset.Tags, tags);
        }
示例#10
0
        public void DeleteJobCheckTestParsArg()
        {
            string jobUuid = "JobUUID";
            string name    = "NAME";

            string[]          argv = null;
            var               commandLineParser = new CommandLine.Parser();
            CommandLineParser parser            = new CommandLineParser(new OptionConverter(new JsonDeserializer()), commandLineParser, new ParserUsage(), new VerbFormater());
            IConfiguration    iConfSet          = null;

            argv     = new string[] { "job", "delete", "--name", name, "--id", jobUuid };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is DefaultRunConfiguration))
            {
                throw new Exception("return value is not DefaultRunConfiguration ");
            }

            DefaultRunConfiguration confset = (DefaultRunConfiguration)iConfSet;

            Assert.AreEqual(confset.Type, ConfigType.Job);
            Assert.AreEqual(confset.Command, CommandApi.Delete);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Id, jobUuid);

            argv     = new string[] { "job", "delete", "-n", name, "-i", jobUuid };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is DefaultRunConfiguration))
            {
                throw new Exception("return value is not DefaultRunConfiguration ");
            }

            confset = (DefaultRunConfiguration)iConfSet;
            Assert.AreEqual(confset.Type, ConfigType.Job);
            Assert.AreEqual(confset.Command, CommandApi.Delete);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Id, jobUuid);
            commandLineParser.Dispose();
        }
示例#11
0
        public void UploadTaskResourcesCheckTestParsArg()
        {
            string taskUuid = "TaskUUID";
            string name     = "NAME";
            string tags     = "TAG1,TAG2";

            string[] argv = null;
            using var commandLineParser = new CommandLine.Parser();
            CommandLineParser parser   = new CommandLineParser(new OptionConverter(new JsonDeserializer()), commandLineParser, new ParserUsage(), new VerbFormater());
            IConfiguration    iConfSet = null;

            argv     = new string[] { "task", "update-resources", "--name", name, "--id", taskUuid, "--tags", tags };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is DefaultRunConfiguration))
            {
                throw new Exception("return value is not DefaultRunConfiguration ");
            }

            DefaultRunConfiguration confset = (DefaultRunConfiguration)iConfSet;

            Assert.AreEqual(confset.Type, ConfigType.Task);
            Assert.AreEqual(confset.Command, CommandApi.UpdateResources);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Id, taskUuid);

            argv     = new string[] { "task", "update-resources", "-n", name, "-i", taskUuid, "-t", tags };
            iConfSet = parser.Parse(argv);

            if (!(iConfSet is DefaultRunConfiguration))
            {
                throw new Exception("return value is not DefaultRunConfiguration ");
            }

            confset = (DefaultRunConfiguration)iConfSet;
            Assert.AreEqual(confset.Type, ConfigType.Task);
            Assert.AreEqual(confset.Command, CommandApi.UpdateResources);
            Assert.AreEqual(confset.Name, name);
            Assert.AreEqual(confset.Id, taskUuid);
        }