Пример #1
0
        public void Int64Option()
        {
            CommandLineUtilities.Option opt = default(CommandLineUtilities.Option);

            opt.Name  = "Switch";
            opt.Value = "12";
            Assert.Equal(12, CommandLineUtilities.ParseInt64Option(opt, 0, 100));

            opt.Name  = "Switch";
            opt.Value = "0";
            Assert.Equal(0, CommandLineUtilities.ParseInt64Option(opt, 0, 100));

            opt.Name  = "Switch";
            opt.Value = "100";
            Assert.Equal(100, CommandLineUtilities.ParseInt64Option(opt, 0, 100));

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

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

            Assert.Throws <InvalidArgumentException>(() =>
            {
                opt.Name  = "Switch";
                opt.Value = "-1";
                CommandLineUtilities.ParseInt64Option(opt, 0, 100);
            });

            Assert.Throws <InvalidArgumentException>(() =>
            {
                opt.Name  = "Switch";
                opt.Value = "101";
                CommandLineUtilities.ParseInt64Option(opt, 0, 100);
            });
        }