Example #1
0
        public void AcceptsBothParametersInAnyOrder()
        {
            var parameters1 = new CleanParameters(new[] { "--soft-clean", "--keep-refs" });

            parameters1.SoftClean.Should().BeTrue();
            parameters1.KeepReferences.Should().BeTrue();

            var parameters2 = new CleanParameters(new[] { "--keep-references", "--soft-clean" });

            parameters2.SoftClean.Should().BeTrue();
            parameters2.KeepReferences.Should().BeTrue();
        }
Example #2
0
        /// <summary>
        /// Runs the command
        /// </summary>
        /// <param name="suite">The current suite model the command is applied to</param>
        /// <param name="parameters">Parameters given to the command (in unprocessed form)</param>
        public bool Run(Suite suite, string[] parameters)
        {
            var cleanParams = new CleanParameters(new string[0]);

            var cleanParameters = parameters.Where(cleanParams.IsKeepReferencesParameter).ToArray();
            var buildParameters = parameters.Where(p => !cleanParams.IsKeepReferencesParameter(p)).ToArray();

            var cleanSucceeded = cleanCommand.Run(suite, cleanParameters);

            targetRoot.Remake();
            cacheRoot.Remake();

            var buildSucceeded = buildCommand.Run(suite, buildParameters);

            return(cleanSucceeded && buildSucceeded);
        }
Example #3
0
        public DataSet ExecuteDataSet(string query, CommandType commandtype, ConnectionState connectionstate, ParameterError parameterError, CleanParameters cleanParameters)
        {
            DbDataAdapter adapter = objFactory.CreateDataAdapter();

            if (parameterError == ParameterError.include)
            {
                addParameterError();
            }

            objCommand.CommandText = query;
            objCommand.CommandType = commandtype;
            adapter.SelectCommand  = objCommand;
            DataSet ds = new DataSet();

            try
            {
                adapter.Fill(ds);

                if (parameterError == ParameterError.include)
                {
                    string error = objCommand.Parameters[DBHelper.MENSAJE_ERROR].Value.ToString();
                    if (error != string.Empty)
                    {
                        throw new ValidatorException(error);
                    }
                }
            }
            catch (Exception ex)
            {
                HandleExceptions(ex);
            }
            finally
            {
                if (cleanParameters == CleanParameters.clean)
                {
                    objCommand.Parameters.Clear();
                }
                if (connectionstate == ConnectionState.CloseOnExit)
                {
                    if (objConnection.State == System.Data.ConnectionState.Open)
                    {
                        objConnection.Close();
                    }
                }
            }
            return(ds);
        }
Example #4
0
        public DbDataReader ExecuteReader(string query, CommandType commandtype, ConnectionState connectionstate, ParameterError parameterError, CleanParameters cleanParameters)
        {
            objCommand.CommandText = query;
            objCommand.CommandType = commandtype;
            DbDataReader reader = null;

            try
            {
                if (parameterError == ParameterError.include)
                {
                    addParameterError();
                }

                if (objConnection.State == System.Data.ConnectionState.Closed)
                {
                    objConnection.Open();
                }
                if (connectionstate == ConnectionState.CloseOnExit)
                {
                    reader = objCommand.ExecuteReader(CommandBehavior.CloseConnection);
                }
                else
                {
                    reader = objCommand.ExecuteReader();
                }

                if (parameterError == ParameterError.include)
                {
                    string error = objCommand.Parameters[DBHelper.MENSAJE_ERROR].Value.ToString();
                    if (error != string.Empty)
                    {
                        throw new ValidatorException(error);
                    }
                }
            }
            catch (Exception ex)
            {
                HandleExceptions(ex);
            }
            finally
            {
                if (cleanParameters == CleanParameters.clean)
                {
                    objCommand.Parameters.Clear();
                }
            }

            return(reader);
        }
Example #5
0
        public int ExecuteNonQuery(string query, CommandType commandtype, ConnectionState connectionstate, ParameterError parameterError, CleanParameters cleanParameters)
        {
            objCommand.CommandText = query;
            objCommand.CommandType = commandtype;
            if (parameterError == ParameterError.include)
            {
                addParameterError();
            }

            int i = -1;

            try
            {
                if (objConnection.State == System.Data.ConnectionState.Closed)
                {
                    objConnection.Open();
                }
                i = objCommand.ExecuteNonQuery();

                if (parameterError == ParameterError.include)
                {
                    string error = objCommand.Parameters[DBHelper.MENSAJE_ERROR].Value.ToString();
                    if (error != string.Empty)
                    {
                        throw new ValidatorException(error);
                    }
                }
            }
            catch (Exception ex)
            {
                HandleExceptions(ex);
            }
            finally
            {
                if (cleanParameters == CleanParameters.clean)
                {
                    objCommand.Parameters.Clear();
                }

                if (connectionstate == ConnectionState.CloseOnExit)
                {
                    //objConnection.Close();
                }
            }

            return(i);
        }
Example #6
0
        public void AcceptsAlternativeKeepReferencesParameter()
        {
            var parameters = new CleanParameters(new[] { "--keep-refs" });

            parameters.KeepReferences.Should().BeTrue();
        }
Example #7
0
        public void ByDefaultDoesNotKeepReferences()
        {
            var parameters = new CleanParameters(new string[0]);

            parameters.KeepReferences.Should().BeFalse();
        }
Example #8
0
        public void AcceptsSoftCleanParameter()
        {
            var parameters = new CleanParameters(new[] { "--soft-clean" });

            parameters.SoftClean.Should().BeTrue();
        }
Example #9
0
        public void ByDefaultNoSoftClean()
        {
            var parameters = new CleanParameters(new string[0]);

            parameters.SoftClean.Should().BeFalse();
        }