Beispiel #1
0
        public void RouteCommand_HandlerHasFlagsynonymDefined_FlagIsRoutedBasedOnThesynonym()
        {
            //Arrange
            bool commandInvoked = false;
            bool passedForceMergeFlagValue = false;
            CommandContainerForTests.MergeCommand5Callback
                = force =>
                      {
                          commandInvoked = true;
                          passedForceMergeFlagValue = force;
                      };

            //Act
            var router = new Router();
            router.Route(new[] { "MergeCommand5", "-f" });

            //Assert
            Assert.IsTrue(commandInvoked);
            Assert.IsTrue(passedForceMergeFlagValue);
        }
Beispiel #2
0
        public void RouteCommand_HandlerHasCommandNameDefined_CommandIsRoutedBasedOnCommandNameNotMethodName()
        {
            bool commandInvoked = false;
            CommandContainerForTests.MergeCommand4Callback = () => commandInvoked = true;

            var router = new Router();
            router.Route(new[] { "mergeall" });

            Assert.IsTrue(commandInvoked);
        }
Beispiel #3
0
        public void RouteCommand_StaticMethodWithoutOneFlagAndOneArgument_FlagIsNotPassedButArgumentIsPassed_ArgumentIsPassedToHandlerFlagIsDefault()
        {
            //Arrange
            bool commandInvoked = false;
            bool passedForceMergeFlagValue = false;
            string passedBranchNameValue = "";
            CommandContainerForTests.MergeCommand3Callback
                = (branchName, forceMerge) =>
                {
                    commandInvoked = true;
                    passedForceMergeFlagValue = forceMerge;
                    passedBranchNameValue = branchName;
                };

            //Act
            var router = new Router();
            router.Route(new[] { "MergeCommand3", "SuperBranch" });

            //Assert
            Assert.IsTrue(commandInvoked);
            Assert.That(passedBranchNameValue, Is.EqualTo("SuperBranch"));
            Assert.IsFalse(passedForceMergeFlagValue);
        }
Beispiel #4
0
        public void RouteCommand_StaticMethodWithoutOneFlagFlagIsPassed_FlagValueIsPassedToTheHandler()
        {
            //Arrange
            bool commandInvoked = false;
            bool passedForceMergeFlagValue = false;
            CommandContainerForTests.MergeCommand2Callback
                = forceMerge =>
                {
                    commandInvoked = true;
                    passedForceMergeFlagValue = forceMerge;
                };

            //Act
            var router = new Router();
            router.Route(new[] { "MergeCommand2", "forceMerge" });

            //Assert
            Assert.IsTrue(commandInvoked);
            Assert.IsTrue(passedForceMergeFlagValue);
        }
Beispiel #5
0
        public void RouteCommand_StaticMethodWithoutAttributes_IsRouted()
        {
            bool mergeCommandInvoked = false;
            CommandContainerForTests.MergeCommandCallback = () => mergeCommandInvoked = true;

            var router = new Router();
            router.Route(new [] {"MergeCommand"});

            Assert.IsTrue(mergeCommandInvoked);
        }