コード例 #1
0
        public void SingletonPathOption()
        {
            CommandLineUtilities.Option opt = default(CommandLineUtilities.Option);

            opt.Name  = "Switch";
            opt.Value = "test.dll";
            Assert.Equal(Path.Combine(Directory.GetCurrentDirectory(), "test.dll"), CommandLineUtilities.ParseSingletonPathOption(opt, null));

            if (!OperatingSystemHelper.IsUnixOS)
            {
                opt.Name  = "Switch";
                opt.Value = SpecialFolderUtilities.GetFolderPath(SpecialFolder.Windows);
                Assert.Equal(opt.Value, CommandLineUtilities.ParseSingletonPathOption(opt, null));
            }

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

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

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