Exemplo n.º 1
0
        public void ExecuteCommand_WithNoVerb_WritesResponse()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);

            underTest.ExecuteCommand("cmd");
            Assert.IsTrue(testWriter.Contains("The command 'cmd' requires a verb."));
        }
Exemplo n.º 2
0
        public void ExecuteCommand_WithInvalidVerb_WritesResponse()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);

            underTest.ExecuteCommand("cmd not");
            Assert.IsTrue(testWriter.Contains("No verb with the specified name 'not' exists."));
        }
Exemplo n.º 3
0
        public void ExecuteCommand_ProcessesException()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);

            underTest.ExecuteCommand("cmd x");

            Assert.IsTrue(testWriter.Contains("TEST MESSAGE") && testWriter.Contains("System.NullReferenceException"));
        }
Exemplo n.º 4
0
        public void ConvertParameter_ConvertsType_Failure5()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);

            underTest.ExecuteCommand("cmd typeTest --bool1 --bool2 yes --bool3 no --bool4 on --bool5 off --bool6 true --int1 123 --int2 132 --int3 123 --int4 123 --int5 gbg");

            Assert.IsFalse(testWriter.Contains("SUCCESS"));
        }
Exemplo n.º 5
0
        public void ExecuteCommand_WithNoOptionalFlag_ExecutesCommand()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);

            underTest.ExecuteCommand("cmd opt");

            Assert.IsTrue(testWriter.Contains("OPTIONAL"));
        }
Exemplo n.º 6
0
        public void ConvertParameter_ConvertsType_Success()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);

            underTest.ExecuteCommand("cmd typeTest --bool1 --bool2 yes --bool3 no --bool4 on --bool5 off --bool6 true --int1 \"-123\" --int2 65535 --int3 123 --int4 123.43 --int5 423123");

            Assert.IsTrue(testWriter.Contains("SUCCESS"));
        }
Exemplo n.º 7
0
        public void BasicCommand_WithInvalidParamType_WritesMessage()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);

            underTest.ExecuteCommand("cmd some --a bah");

            Assert.IsTrue(testWriter.Contains("Unable to convert the operand 'a' with the value 'bah' to the expected type value 'System.Boolean'."));
        }
Exemplo n.º 8
0
        public void BasicCommand_PerformsAction_Coverage5()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);

            underTest.ExecuteCommand("cmd some -v -x");

            Assert.IsTrue(testWriter.Contains("The verb 'some' requires a different combination of operands than what was provided."));
        }
Exemplo n.º 9
0
        public void BasicCommand_PerformsAction_Coverage4()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);

            underTest.ExecuteCommand("cmd some -v");

            Assert.IsTrue(testWriter.Contains("NOTHING"));
        }
Exemplo n.º 10
0
        public void ExecuteCommand_WithDefaultValue_Coverage()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);
            var handled = false;

            underTest.CommandExceptionEncountered += (o, a) => handled = true;
            underTest.ExecuteCommand("cmd not value");
            Assert.IsFalse(handled);
        }
Exemplo n.º 11
0
        public void DuplicateOperand_WritesError()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);

            underTest.ExecuteCommand("cmd v --f temp --f");

            Assert.IsTrue(testWriter.Contains("Duplicate operand or flag names are not allowed!"));
            Assert.IsFalse(testWriter.Contains("NOTHING"));
        }
Exemplo n.º 12
0
        public void ExecuteCommand_Handler_ProcessesException()
        {
            var c = new InvalidInternals();

            underTest.AddCommand(c);
            var handled = false;
            EventHandler <TerminalCommandExceptionEventArgs> handler = (o, a) => handled = true;

            underTest.CommandExceptionEncountered += handler;
            underTest.ExecuteCommand("cmd x2");
            underTest.CommandExceptionEncountered -= handler;
            Assert.IsTrue(handled);
        }