Esempio n. 1
0
        public void OptionBuilder_CreateOption_Command_Found_No_SubCommands()
        {
            string expectedCommand         = "Storage";
            int    expectedNumberOfOptions = 0;

            string environmentSetting = $"{{\"UseLiveClient\": \"True\"}}";
            NullLogger <Microsoft.Extensions.Logging.ILogger> logger = new NullLogger <Microsoft.Extensions.Logging.ILogger>();

            BuildEnvironment(environmentSetting);

            CfgCommand command = TestDataBuilder.CreateCfgCommand(expectedCommand);

            CfgCommandList commandList = new CfgCommandList();

            commandList.Commands = new List <CfgCommand>();
            commandList.Commands.Add(command);

            OptionBuilder builder = OptionBuilder.Instance(logger);

            builder.CfgCommands = commandList;

            GetDataHandler handler = new GetDataHandler(new NullLogger <GetDataHandler>());

            List <IOption> selectableOptions = builder.BuildAvailableOptions(handler);

            Assert.AreEqual(expectedNumberOfOptions, selectableOptions.Count);
        }
Esempio n. 2
0
        public void OptionBuilder_CreateOption_Command_Found_One_Option()
        {
            string expectedCommand     = "Storage";
            string expectedSubCommand  = "GetData";
            string expectedOption      = "TestOption";
            string expectedDataType    = "string";
            string expectedDescription = "Option test description";
            string expectedApiName     = "TestApiName";

            int expectedNumberOfOptions = 1;

            string environmentSetting = $"{{\"UseLiveClient\": \"True\"}}";
            NullLogger <Microsoft.Extensions.Logging.ILogger> logger = new NullLogger <Microsoft.Extensions.Logging.ILogger>();

            BuildEnvironment(environmentSetting);

            CfgCommand    command    = TestDataBuilder.CreateCfgCommand(expectedCommand);
            CfgSubCommand subCommand = TestDataBuilder.CreateCfgSubCommand(expectedSubCommand);

            command.SubCommands.Add(subCommand);
            CfgOption option = TestDataBuilder.CreateCfgOption(expectedOption, expectedDataType, expectedDescription, expectedApiName);

            subCommand.Options.Add(option);

            CfgCommandList commandList = new CfgCommandList();

            commandList.Commands = new List <CfgCommand>();
            commandList.Commands.Add(command);

            OptionBuilder builder = OptionBuilder.Instance(logger);

            builder.CfgCommands = commandList;

            GetDataHandler handler = new GetDataHandler(new NullLogger <GetDataHandler>());

            List <IOption> selectableOptions = builder.BuildAvailableOptions(handler);

            Assert.AreEqual(expectedNumberOfOptions, selectableOptions.Count);
            IOption selectableOption = selectableOptions[0];

            Assert.AreEqual(expectedOption, selectableOption.Name);
            Assert.AreEqual(expectedDescription, selectableOption.Description);
            Assert.AreEqual(expectedApiName, selectableOption.ApiName);
            Assert.IsFalse(selectableOption.IsAssigned);
            Assert.IsInstanceOfType(selectableOption, typeof(NumberOption <string>));
        }