Exemplo n.º 1
0
        public void FileParameterAndUnnamedParameterCauseConflict()
        {
            var program = new MockedProgram(new string[]
            {
                ParameterUtils.FileArgumentParameter,
                "file1",
                "file2"
            });
            program.Execute();

            program.AssertMainProgramRoutineNotRun();

            Assert.IsNotNull(program.ThrownOptionException, "Expecting an option exception");
            Assert.IsNotNull(program.ThrownOptionException.InnerException);
            Assert.IsInstanceOfType(program.ThrownOptionException.InnerException,
                typeof(ConflictingOptionsException));
            Assert.AreEqual(2,
                (program.ThrownOptionException.InnerException as ConflictingOptionsException).Options.Count(),
                "Expecting 2 conflicting options!");
            Assert.AreEqual(Program.UnnamedArgumentName,
                (program.ThrownOptionException.InnerException as ConflictingOptionsException).Options.ElementAt(0),
                "Conflicting option does not match expected!");
            Assert.AreEqual(Program.FileArgumentName,
                (program.ThrownOptionException.InnerException as ConflictingOptionsException).Options.ElementAt(1),
                "Conflicting option does not match expected!");
        }
Exemplo n.º 2
0
        public void MoreUnnamedParametersCauseError()
        {
            var value1 = "file1";
            var value2 = "file2";

            var program = new MockedProgram(new string[]
            {
                value1,
                value2
            });
            program.Execute();

            program.AssertMainProgramRoutineNotRun();

            Assert.IsNotNull(program.ThrownOptionException, "Expecting an option exception");
            Assert.IsNotNull(program.ThrownOptionException.InnerException);
            Assert.IsInstanceOfType(program.ThrownOptionException.InnerException,
                typeof(DefaultOptionException));
            Assert.AreEqual(2,
                (program.ThrownOptionException.InnerException as DefaultOptionException).OptionsValues.Count(),
                "Expecting 2 conflicting options!");
            Assert.AreEqual(value1,
                (program.ThrownOptionException.InnerException as DefaultOptionException).OptionsValues.ElementAt(0),
                "Conflicting option does not match expected!");
            Assert.AreEqual(value2,
                (program.ThrownOptionException.InnerException as DefaultOptionException).OptionsValues.ElementAt(1),
                "Conflicting option does not match expected!");
        }