Ejemplo n.º 1
0
        public void DuplicateArgsShouldThrow()
        {
            migrate::CmdLine.CommandLine.CommandEnvironment = new TestCommandEnvironment("/N:123 /N:345");

            var commandArg = new migrate::CmdLine.CommandArgument("/N:345", 7);

            commandArg.Command = "N";
            Assert.Equal(
                new migrate::CmdLine.CommandLineArgumentInvalidException(typeof(string), commandArg).Message,
                Assert.Throws <migrate::CmdLine.CommandLineArgumentInvalidException>(() => migrate::CmdLine.CommandLine.Parse <TestArgs>()).
                Message);
        }
Ejemplo n.º 2
0
        public void NoMatchingPropertyWithInferredShouldThrow()
        {
            var args = new[] { "/NoMatch" };

            migrate::CmdLine.CommandLine.CommandEnvironment = new TestCommandEnvironment(args);

            var commandArg = new migrate::CmdLine.CommandArgument("/NoMatch", 0);

            commandArg.Command = "NoMatch";
            Assert.Equal(
                new migrate::CmdLine.CommandLineArgumentInvalidException(typeof(string), commandArg).Message,
                Assert.Throws <migrate::CmdLine.CommandLineArgumentInvalidException>(
                    () => migrate::CmdLine.CommandLine.Parse <InferredTestArgs>()).Message);
        }
Ejemplo n.º 3
0
        [Fact] // CodePlex 1107
        public void Deserialized_exception_can_be_serialized_and_deserialized_again()
        {
            var commandArg = new migrate::CmdLine.CommandArgument("/N:345", 7);
            commandArg.Command = "N";

            var ex = new migrate::CmdLine.CommandLineArgumentInvalidException(
                typeof(CommandLineExceptionTests.SomeCommandLineClass), commandArg);
            
            Assert.Contains("/N:345", ex.Message);

            Assert.Contains(
                "/N:345", 
                ExceptionHelpers.SerializeAndDeserialize(ExceptionHelpers.SerializeAndDeserialize(ex)).Message);
        }
Ejemplo n.º 4
0
        [Fact] // CodePlex 1107
        public void Deserialized_exception_can_be_serialized_and_deserialized_again()
        {
            var commandArg = new migrate::CmdLine.CommandArgument("/N:345", 7);

            commandArg.Command = "N";

            var ex = new migrate::CmdLine.CommandLineRequiredArgumentMissingException(
                typeof(CommandLineExceptionTests.SomeCommandLineClass), "/N:345", 7);

            Assert.Contains("/N:345", ex.Message);

            Assert.Contains(
                "/N:345",
                ExceptionHelpers.SerializeAndDeserialize(ExceptionHelpers.SerializeAndDeserialize(ex)).Message);
        }
Ejemplo n.º 5
0
        public void NoMatchingPropertyWithInferredShouldThrow()
        {
            var args = new[] { "/NoMatch" };

            migrate::CmdLine.CommandLine.CommandEnvironment = new TestCommandEnvironment(args);

            var commandArg = new migrate::CmdLine.CommandArgument("/NoMatch", 0);
            commandArg.Command = "NoMatch";
            Assert.Equal(
                new migrate::CmdLine.CommandLineArgumentInvalidException(typeof(string), commandArg).Message,
                Assert.Throws<migrate::CmdLine.CommandLineArgumentInvalidException>(
                    () => migrate::CmdLine.CommandLine.Parse<InferredTestArgs>()).Message);
        }
Ejemplo n.º 6
0
        public void DuplicateArgsShouldThrow()
        {
            migrate::CmdLine.CommandLine.CommandEnvironment = new TestCommandEnvironment("/N:123 /N:345");

            var commandArg = new migrate::CmdLine.CommandArgument("/N:345", 7);
            commandArg.Command = "N";
            Assert.Equal(
                new migrate::CmdLine.CommandLineArgumentInvalidException(typeof(string), commandArg).Message,
                Assert.Throws<migrate::CmdLine.CommandLineArgumentInvalidException>(() => migrate::CmdLine.CommandLine.Parse<TestArgs>()).
                    Message);
        }