Пример #1
0
 private void DeleteUserName(string userName)
 {
     _commonDatabase.ExecuteNonQuery(CommandType.Text,
                                     "DELETE " + Framework.Dao.Constants.DefaultTableUsers + " WHERE username = '******'",
                                     false,
                                     Framework.Tests.DataServices.CommonDatabase.CurrentUser);
 }
Пример #2
0
 public void Init(string [] queries)
 {
     foreach (string query in queries)
     {
         if (!string.IsNullOrEmpty(query))
         {
             _commonDatabase.ExecuteNonQuery(System.Data.CommandType.Text, query, false, _currentUser);
         }
     }
 }
Пример #3
0
        public void ExecuteStoredProcedureToNonQueryWithoutParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);

            int result = commonDatabase.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_select_users_nonquery", false, CurrentUser);
        }
Пример #4
0
        public void ExecuteTextToNonQueryWithoutParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);

            int result = commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "SELECT * FROM Users", false, CurrentUser);
        }
Пример #5
0
        public void ExecuteStoredProcedureToNonQueryWithIntParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);

            int result = commonDatabase.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_select_users_nonquery", false, CurrentUser,
                commonDatabase.Parameters.Create("@Children", DbType.Int32, ParameterDirection.Input, 1));
        }
Пример #6
0
        public void FailedToExecutStoredProcedureToNonQueryInWrongStoredProcedure()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);

            int result = commonDatabase.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_select_users_fail", false, CurrentUser,
                commonDatabase.Parameters.Create("@BirthDate", DbType.Date, ParameterDirection.Input, DateTime.Now),
                commonDatabase.Parameters.Create("@Children", DbType.Int32, ParameterDirection.Input, 1));
        }
Пример #7
0
        public void ExecuteStoredProcedureToNonQueryWithDefaultOutputParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);

            int result = commonDatabase.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_select_users_outputparameters", true, CurrentUser);


            Assert.AreEqual(commonDatabase.ExecutionStatus.ErrorNumber, 10);
            Assert.AreEqual(commonDatabase.ExecutionStatus.ErrorDescription, "User: "******" - Number: 10");
            Assert.AreEqual(commonDatabase.ExecutionStatus.CurrentUser, CurrentUser);
        }
Пример #8
0
        public void ExecuteTextToNonQueryWithIntParameters()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);


            Framework.DataServices.ParameterConfiguration parameterConfig =
                new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider());


            int result = commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "SELECT * FROM Users WHERE Children > @Children", false, CurrentUser,
                parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 0));
        }
Пример #9
0
        public void FailedToExecuteTextToNonQueryInWrongFieldName()
        {
            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName);


            Framework.DataServices.ParameterConfiguration parameterConfig =
                new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider());


            int result = commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "SELECT * FROM Users_Fail " +
                " WHERE Children > @Children " +
                "   AND BirthDateFail < @BirthDate ", false, CurrentUser,
                parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 1),
                parameterConfig.Create("@BirthDate", DbType.Date, ParameterDirection.Input, DateTime.Now));
        }
Пример #10
0
        public void Cleanup()
        {
            _connectionStringSettings = new ConnectionStringSettings(Constants.ConnectionName, Constants.ConnectionString, Constants.ProviderName);


            Framework.DataServices.CommonDatabase commonDatabase =
                new Framework.DataServices.CommonDatabase(
                    _connectionStringSettings.Name,
                    _connectionStringSettings.ConnectionString,
                    _connectionStringSettings.ProviderName);


            commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "DELETE FROM " + Framework.Dao.Constants.DefaultTableUsers +
                " WHERE UserName='******'",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);
        }
Пример #11
0
        protected void btnTestInsertCommon_Click(object sender, EventArgs e)
        {
            try
            {
                Framework.DataServices.CommonDatabase db = new Framework.DataServices.CommonDatabase("DBProvider");
                db.ExecuteNonQuery(CommandType.Text, "INSERT INTO Users (UserName) VALUES ('XXXXYYYY')", false, "thoris");
            }
            catch (Exception ex)
            {
                this.lblStatusIUDCommon.Text = "Erro ao inserir o registro. " + ex.Message;
                return;
            }

            try
            {
                Framework.DataServices.CommonDatabase db = new Framework.DataServices.CommonDatabase("DBProvider");
                db.ExecuteNonQuery(CommandType.Text, "UPDATE Users SET CreatedBy = 'test' WHERE UserName ='******'", false, "thoris");
            }
            catch (Exception ex)
            {
                this.lblStatusIUDCommon.Text = "Erro ao atualizar o registro. " + ex.Message;
                return;
            }


            try
            {
                Framework.DataServices.CommonDatabase db = new Framework.DataServices.CommonDatabase("DBProvider");
                db.ExecuteNonQuery(CommandType.Text, "DELETE FROM Users WHERE UserName ='******'", false, "thoris");

                this.lblStatusIUDCommon.Text = "Dados atualizados com sucesso.";
            }
            catch (Exception ex)
            {
                this.lblStatusIUDCommon.Text = "Erro ao excluir o registro. " + ex.Message;
                return;
            }
        }
Пример #12
0
        public void Init()
        {
            _connectionStringSettings = new ConnectionStringSettings(Constants.ConnectionName, Constants.ConnectionString, Constants.ProviderName);


            _commonDatabase = new Framework.DataServices.CommonDatabase(
                _connectionStringSettings.Name,
                _connectionStringSettings.ConnectionString,
                _connectionStringSettings.ProviderName);


            //_userDao = new Framework.Security.DataAccess.UserDataDao(Constants.Application,
            //    _connectionStringSettings, Constants.CurrentUser);


            _provider = new Framework.Security.Model.SystemProperties();


            //Delete all users
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "DELETE FROM " + Framework.Dao.Constants.DefaultTableUsers,
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            //Manage user existing
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, Password) VALUES ('" + DataAccess.UserDataDao.ExistingUser + "','" + DataAccess.UserDataDao.OldPassword + "')",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            //User to approve
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, IsApproved) VALUES ('" + DataAccess.UserDataDao.UserToApprove + "'," + "0" + ")",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            //User to Change the password
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, Password) VALUES ('" + DataAccess.UserDataDao.UserToChangePassword + "','" + DataAccess.UserDataDao.OldPassword + "')",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);


            //User to Change the answer
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, Password, PasswordQuestion, PasswordAnswer) VALUES ('" +
                DataAccess.UserDataDao.UserToChangeAnswer + "','" + DataAccess.UserDataDao.OldPassword + "','" +
                DataAccess.UserDataDao.OldQuestion + "','" + DataAccess.UserDataDao.OldAnswer + "')",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            //User to desapprove
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, IsApproved) VALUES ('" + DataAccess.UserDataDao.UserToDesapprove + "'," + "1" + ")",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            //User to get the password
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, Password, PasswordAnswer, IsLockedOut) VALUES ('" + DataAccess.UserDataDao.UserToGetPassword + "','"
                + DataAccess.UserDataDao.OldPassword + "','" + DataAccess.UserDataDao.OldAnswer + "', 0)",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);


            //User to lock
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, IsLockedOut) VALUES ('" + DataAccess.UserDataDao.UserToLock + "', 0)",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            //User to Reset Password
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, Password, PasswordQuestion, PasswordAnswer, IsLockedOut) VALUES ('" +
                DataAccess.UserDataDao.UserToResetPassword + "','" + DataAccess.UserDataDao.OldPassword + "','" +
                DataAccess.UserDataDao.OldQuestion + "','" + DataAccess.UserDataDao.OldAnswer + "', 0)",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            //User to Set the password
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, Password) VALUES ('" + DataAccess.UserDataDao.UserToSetPassword + "','" + DataAccess.UserDataDao.OldPassword + "')",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);


            //User to Unlock
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, IsLockedOut) VALUES ('" + DataAccess.UserDataDao.UserToUnLock + "', 1)",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);

            //User to Validate
            _commonDatabase.ExecuteNonQuery(
                CommandType.Text,
                "INSERT INTO " + Framework.Dao.Constants.DefaultTableUsers +
                "(UserName, Password) VALUES ('" + DataAccess.UserDataDao.UserToValidate + "', '" +
                DataAccess.UserDataDao.OldPassword + "')",
                false,
                Framework.Tests.DataServices.CommonDatabase.CurrentUser);
        }