/// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="navigator">The navigator.</param>
        /// <returns>True if the command succeeded.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="navigator"/> is null.</exception>
        public bool Execute(IGallioNavigator navigator)
        {
            if (navigator == null)
            {
                throw new ArgumentNullException("navigator");
            }

            try
            {
                switch (name)
                {
                case NavigateToCommandName:
                    string path         = arguments["path"];
                    int    lineNumber   = GetIntArgument("line", 0);
                    int    columnNumber = GetIntArgument("column", 0);
                    return(navigator.NavigateTo(path, lineNumber, columnNumber));
                }

                Debug.WriteLine(String.Format("Gallio did not understand the command: {0}.", name));
                return(false);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(String.Format("Gallio could not perform requested service due to an exception: {0}.", ex));
                return(false);
            }
        }
Ejemplo n.º 2
0
        public void NavigateTo(bool simulateSuccess)
        {
            MockRepository mocks = new MockRepository();

            IGallioNavigator navigator = mocks.StrictMock <IGallioNavigator>();

            using (mocks.Record())
            {
                Expect.Call(navigator.NavigateTo(
                                @"C:\Source\MbUnit\v3\src\Gallio\Gallio.Tests\Reflection\Impl\CecilReflectionPolicyTest.cs", 5, 11))
                .Return(simulateSuccess);
            }

            using (mocks.Playback())
            {
                InstrumentedProgram program = new InstrumentedProgram();
                program.Engine = navigator;
                int returnCode = program.Run(new string[]
                {
                    @"gallio:navigateTo?path=C:\Source\MbUnit\v3\src\Gallio\Gallio.Tests\Reflection\Impl\CecilReflectionPolicyTest.cs&line=5&column=11"
                });

                Assert.IsFalse(program.HelpCalled);
                Assert.AreEqual(simulateSuccess ? 0 : 1, returnCode);

                mocks.VerifyAll();
            }
        }
Ejemplo n.º 3
0
        internal int Run(string[] args)
        {
            if (args.Length != 1)
            {
                ShowHelp();
                return(1);
            }

            GallioNavigatorCommand command = GallioNavigatorCommand.ParseUri(args[0]);

            if (command == null)
            {
                return(1);
            }

            IGallioNavigator engine = CreateNavigatorEngine();

            return(command.Execute(engine) ? 0 : 1);
        }
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="navigator">The navigator.</param>
        /// <returns>True if the command succeeded.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="navigator"/> is null.</exception>
        public bool Execute(IGallioNavigator navigator)
        {
            if (navigator == null)
                throw new ArgumentNullException("navigator");

            try
            {
                switch (name)
                {
                    case NavigateToCommandName:
                        string path = arguments["path"];
                        int lineNumber = GetIntArgument("line", 0);
                        int columnNumber = GetIntArgument("column", 0);
                        return navigator.NavigateTo(path, lineNumber, columnNumber);
                }

                Debug.WriteLine(String.Format("Gallio did not understand the command: {0}.", name));
                return false;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(String.Format("Gallio could not perform requested service due to an exception: {0}.", ex));
                return false;
            }
        }