Exemplo n.º 1
0
        public void SingletonStringOption()
        {
            CommandLineUtilities.Option opt = default(CommandLineUtilities.Option);

            opt.Name  = "Switch";
            opt.Value = "Value";
            Assert.Equal(opt.Value, CommandLineUtilities.ParseSingletonStringOption(opt, null));

            Assert.Throws <InvalidArgumentException>(() =>
            {
                opt.Name  = "Switch";
                opt.Value = null;
                CommandLineUtilities.ParseSingletonStringOption(opt, null);
            });

            Assert.Throws <InvalidArgumentException>(() =>
            {
                opt.Name  = "Switch";
                opt.Value = string.Empty;
                CommandLineUtilities.ParseSingletonStringOption(opt, null);
            });

            Assert.Throws <InvalidArgumentException>(() =>
            {
                opt.Name  = "Switch";
                opt.Value = "New";
                CommandLineUtilities.ParseSingletonStringOption(opt, "Existing");
            });
        }