Ejemplo n.º 1
0
        public void WHEN_CallingNonpublicMethod_THEN_MethodIsNotExecuted()
        {
            var args = new[] { "nonpublicmethod" };

            CmdLine <TestClassStatic> .Execute(args).Should().Be(-1);

            TestClassStatic.GetMethodInvokedAndReset().Should().BeNull();
        }
Ejemplo n.º 2
0
        public void WHEN_ClassHasStaticMethod_THEN_MethodIsExecuted()
        {
            var args = new[] { "test1", "/arg=str" };

            CmdLine <TestClassStatic> .Execute(args).Should().Be(0);

            TestClassStatic.GetMethodInvokedAndReset().Should().Be("test1");
        }
Ejemplo n.º 3
0
        public void WHEN_MethodHasNullableArgWithDefault_AND_ArgIsNotProvided_THEN_MethodIsExecuted()
        {
            var args = new[] { "nullablewithdefault" };

            CmdLine <TestClassStatic> .Execute(args).Should().Be(0);

            TestClassStatic.GetMethodInvokedAndReset().Should().Be("nullablewithdefault");
        }
Ejemplo n.º 4
0
        public void WHEN_MethodHasNullableArg_AND_ArgIsProvided_THEN_MethodIsExecuted()
        {
            var args = new[] { "nullable", "/value=3" };

            CmdLine <TestClassStatic> .Execute(args).Should().Be(0);

            TestClassStatic.GetMethodInvokedAndReset().Should().Be("nullable");
        }
Ejemplo n.º 5
0
        public void WHEN_MethodHasNullableArg_AND_ArgIsNotProvided_THEN_MethodIsNotExecuted()
        {
            var args = new[] { "nullable" };

            CmdLine <TestClassStatic> .Execute(args).Should().Be(-1);

            TestClassStatic.GetMethodInvokedAndReset().Should().BeNull();
        }
Ejemplo n.º 6
0
        public void WHEN_UsingCustomArgSeparator_AND_ArgIsInvalid_THEN_MethodIsNotExecuted() // AND_ErrorMessageIsDisplayed
        {
            var config = new CmdLineConfig {
                ArgSeparator = ':'
            };
            var args = new[] { "test3", "/count=2", "/list=1,2" };

            CmdLine <TestClassStatic> .Execute(args, config);

            TestClassStatic.GetMethodInvokedAndReset().Should().BeNull();
        }
Ejemplo n.º 7
0
        public void WHEN_ArgLetterCasingIsDifferent_THEN_MethodIsExecuted()
        {
            var args = new[] { "test3", "/Count=1", "/lIst=1" };

            CmdLine <TestClassStatic> .Execute(args).Should().Be(0);

            TestClassStatic.GetMethodInvokedAndReset().Should().Be("test3");
            args = new[] { "TEST3", "/COUNT=2", "/list=1,2" };
            CmdLine <TestClassStatic> .Execute(args).Should().Be(0);

            TestClassStatic.GetMethodInvokedAndReset().Should().Be("test3");
        }
Ejemplo n.º 8
0
        public void WHEN_ArgIsValueTypeArray_THEN_MethodIsExecuted()
        {
            var args = new[] { "test3", "/count=1", "/list=1" };

            CmdLine <TestClassStatic> .Execute(args).Should().Be(0);

            TestClassStatic.GetMethodInvokedAndReset().Should().Be("test3");
            args = new[] { "test3", "/count=2", "/list=1,2" };
            CmdLine <TestClassStatic> .Execute(args).Should().Be(0);

            TestClassStatic.GetMethodInvokedAndReset().Should().Be("test3");
        }
Ejemplo n.º 9
0
        public void WHEN_UsingCustomArgSeparator_THEN_MethodIsExecuted()
        {
            var config = new CmdLineConfig {
                ArgSeparator = ':'
            };
            var args = new[] { "test3", "/count:1", "/list:1" };

            CmdLine <TestClassStatic> .Execute(args, config).Should().Be(0);

            TestClassStatic.GetMethodInvokedAndReset().Should().Be("test3");
            args = new[] { "test3", "/count:2", "/list:1,2" };
            CmdLine <TestClassStatic> .Execute(args, config).Should().Be(0);

            TestClassStatic.GetMethodInvokedAndReset().Should().Be("test3");
        }
Ejemplo n.º 10
0
 public void InitializeTest()
 {
     TestClassStatic.Reset();
 }