public void Update(Framework.DataServices.Model.EntityBaseData entry, string compareQuery, object objToCompare) { int errorNumber = 0; string errorDescription = null; bool result = _daoBase.Update( _currentUser, entry, out errorNumber, out errorDescription); if (result == false) { throw new AssertTestException("Couldn't update the item"); } if (errorNumber != 0) { throw new AssertTestException("There is an error number = " + errorNumber); } if (!string.IsNullOrEmpty(errorDescription)) { throw new AssertTestException("There is an error description = " + errorDescription); } object objResult = _commonDatabase.ExecuteScalar( System.Data.CommandType.Text, compareQuery, false, _currentUser); if (string.Compare(objToCompare.ToString(), objResult.ToString()) != 0) { throw new AssertTestException("Incompatible results between database and object."); } }
public void ExecuteStoredProcedureToScalarWithoutParameters() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); object objResult = commonDatabase.ExecuteScalar( CommandType.StoredProcedure, "sp_select_users_scalar", false, CurrentUser); }
public void ExecuteTextToScalarWithoutParameters() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); object objResult = commonDatabase.ExecuteScalar( CommandType.Text, "SELECT count(*) FROM Users", false, CurrentUser); }
public void ExecuteStoredProcedureToScalarWithIntParameters() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); object objResult = commonDatabase.ExecuteScalar( CommandType.StoredProcedure, "sp_select_users_scalar", false, CurrentUser, commonDatabase.Parameters.Create("@Children", DbType.Int32, ParameterDirection.Input, 1)); }
public void FailedToExecutStoredProcedureToScalarInWrongStoredProcedure() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); object objResult = commonDatabase.ExecuteScalar( 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)); }
public void ExecuteTextToScalarWithIntParameters() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); Framework.DataServices.ParameterConfiguration parameterConfig = new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider()); object objResult = commonDatabase.ExecuteScalar( CommandType.Text, "SELECT count(*) FROM Users WHERE Children > @Children", false, CurrentUser, parameterConfig.Create("@Children", DbType.Int32, ParameterDirection.Input, 0)); }
public void ExecuteTextToScalarWithDataParameters() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); Framework.DataServices.ParameterConfiguration parameterConfig = new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider()); object objResult = commonDatabase.ExecuteScalar( CommandType.Text, "SELECT COUNT(*) FROM Users WHERE BirthDate < @BirthDate", false, CurrentUser, parameterConfig.Create("@BirthDate", DbType.Date, ParameterDirection.Input, DateTime.Now)); }
public void Update(BolaoNet.Business.IBusinessBase entry, string compareQuery) { bool result = entry.Update(); if (result == false) { throw new AssertTestException("It was not possible to update the object."); } object objResult = _commonDatabase.ExecuteScalar( System.Data.CommandType.Text, compareQuery, false, _currentUser); //if (string.Compare(((Model.Campeonato)entry).Descricao, objResult.ToString()) != 0) // throw new AssertTestException("Incompatible results between database and object."); }
public void FailedToExecuteTextToScalarInWrongFieldName() { Framework.DataServices.CommonDatabase commonDatabase = new Framework.DataServices.CommonDatabase(ConnectionName, ConnectionString, ProviderName); Framework.DataServices.ParameterConfiguration parameterConfig = new Framework.DataServices.ParameterConfiguration(commonDatabase.GetProvider()); object objResult = commonDatabase.ExecuteScalar( CommandType.Text, "SELECT count(*) 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)); }
public void FindUsersByEmail() { int totalRecords = -1; MembershipProvider provider = new Framework.Security.Business.UserManagerService(); MembershipUserCollection list = provider.FindUsersByEmail(DataAccess.UserManagerDao.EmailToMatch, DataAccess.UserManagerDao.PageIndex, DataAccess.UserManagerDao.PageSize, out totalRecords); Assert.IsNotNull(list); Assert.AreNotEqual(totalRecords, -1); Assert.AreEqual(totalRecords, list.Count); object result = _commonDatabase.ExecuteScalar(CommandType.Text, "SELECT Count(*) FROM " + Framework.Dao.Constants.DefaultTableUsers + " WHERE email = '" + DataAccess.UserManagerDao.EmailToMatch + "'", true, Framework.Tests.DataServices.CommonDatabase.CurrentUser); Assert.AreEqual(result, totalRecords); }