Bari.Core.Commands.Test.TestCommand.Run C# (CSharp) Method

Run() public method

Runs the command
public Run ( Suite suite, string parameters ) : bool
suite Suite The current suite model the command is applied to
parameters string Parameters given to the command (in unprocessed form)
return bool
        public bool Run(Suite suite, string[] parameters)
        {
            int effectiveLength = parameters.Length;
            bool dumpMode = false;
            bool dumpDepsMode = false;

            if (effectiveLength > 0)
            {
                dumpMode = parameters[effectiveLength - 1] == "--dump";
                dumpDepsMode = parameters[effectiveLength - 1] == "--dump-deps";
            }

            if (dumpMode || dumpDepsMode)
                effectiveLength--;

            if (effectiveLength < 2)
            {
                string targetStr;
                if (effectiveLength == 0)
                    targetStr = String.Empty;
                else
                    targetStr = parameters[0];

                try
                {
                    lastBuildTarget = targetStr;
                    var target = targetParser.ParseTarget(targetStr);

                    var projects = target.TestProjects.ToList();

                    var tests = suite.HasParameters("test") ? suite.GetParameters<Tests>("test") : new Tests();
                    var buildOutputs = RunWithProjects(projects, dumpMode, dumpDepsMode).ToList();

                    if (buildOutputs.Any())
                        return RunTests(tests, projects, buildOutputs);
                    else
                        return false;
                }
                catch (ArgumentException ex)
                {
                    throw new InvalidCommandParameterException("build", ex.Message);
                }
            }
            else
            {
                throw new InvalidCommandParameterException("test", "Test must be called without any parameters");
            }
        }