public DataSet SelectGlAccountTest(IGlAccount glAccount)
        {
            DataSet tableVerify = new DataSet();

            tableVerify = dbEntity.SelectObject(glAccount) as DataSet;
            return(tableVerify);
        }
        public void VerifyCountry()
        {
            ICountry country = BusinessObjectInitializer.CreateCountry();
            Random   random  = new Random();

            country.Code       = DATestUtils.GenerateString(3, true, true);
            country.Name       = DATestUtils.GenerateString(30, true, false);
            country.IdRegion   = random.Next(1, 3);
            country.IdCurrency = random.Next(1, 12);
            country.Rank       = random.Next(100000, 200000);

            int newId = InsertCountryTest(country);

            Assert.Greater(newId, 0);

            int rowsAffected = UpdateCountryTest(country);

            Assert.AreEqual(1, rowsAffected);

            DataTable resultTable = SelectCountryTest(country).Tables[0];

            //Verifies that the table contains the correct column names and order
            StringCollection columns = new StringCollection();

            columns.AddRange(new string[] { "Code",
                                            "Name",
                                            "RegionName",
                                            "CurrencyName",
                                            "Email",
                                            "Rank",
                                            "Id",
                                            "IdRegion",
                                            "IdCurrency" });
            DATestUtils.CheckTableStructure(resultTable, columns);

            try
            {
                //we delete the 7 accounts associated with a country
                GlAccountTest accountTest = new GlAccountTest();
                accountTest.Initialize();
                IGlAccount glAccount = BusinessObjectInitializer.CreateGLAccount();

                glAccount.IdCountry = newId;
                for (int i = 1; i <= 7; i++)
                {
                    glAccount.Id = i;
                    accountTest.DeleteGlAccountTest(glAccount);
                }
                accountTest.CleanUp();
            }
            catch (Exception ex)
            {
                throw new Exception("Pre-Condition failed for delete operation. Gl/account operation meessage: " + ex.Message);
            }

            int rowCount = DeleteCountryTest(country);

            Assert.AreEqual(1, rowCount);
        }
        public void VerifyGlAccount()
        {
            IGlAccount glAccount = BusinessObjectInitializer.CreateGLAccount();

            Random random = new Random();

            glAccount.Name       = DATestUtils.GenerateString(30, true, false);
            glAccount.Account    = DATestUtils.GenerateString(20, true, false);
            glAccount.IdCostType = random.Next(1, 6);
            glAccount.IdCountry  = random.Next(1, 3);

            int newId = InsertGlAccountTest(glAccount);

            Assert.Greater(newId, 0);

            int rowsAffected = UpdateGlAccountTest(glAccount);

            Assert.AreEqual(1, rowsAffected);

            DataTable resultTable = SelectGlAccountTest(glAccount).Tables[0];

            //Verifies that the table contains the correct column names and order
            StringCollection columns = new StringCollection();

            columns.AddRange(new string[] { "CountryName",
                                            "G/L Account",
                                            "Name",
                                            "CostType",
                                            "Id",
                                            "IdCountry",
                                            "IdCostType" });

            DATestUtils.CheckTableStructure(resultTable, columns);

            int rowCount = DeleteGlAccountTest(glAccount);

            Assert.AreEqual(1, rowCount);
        }
        protected override void InitializeObject(IGenericEntity ent)
        {
            if (ent is IGlAccount)
            {
                IGlAccount        GlAccount = (IGlAccount)ent;
                DBStoredProcedure spInsert  = new DBStoredProcedure();
                spInsert.ProcedureName = "catInsertGlAccount";
                spInsert.AddParameter(new DBParameter("@IdCountry", DbType.Int32, ParameterDirection.Input, GlAccount.IdCountry));
                spInsert.AddParameter(new DBParameter("@Account", DbType.String, ParameterDirection.Input, GlAccount.Account));
                spInsert.AddParameter(new DBParameter("@Name", DbType.String, ParameterDirection.Input, GlAccount.Name));
                spInsert.AddParameter(new DBParameter("@IdCostType", DbType.Int32, ParameterDirection.Input, GlAccount.IdCostType));

                DBStoredProcedure spUpdate = new DBStoredProcedure();
                spUpdate.ProcedureName = "catUpdateGlAccount";
                spUpdate.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, GlAccount.Id));
                spUpdate.AddParameter(new DBParameter("@IdCountry", DbType.Int32, ParameterDirection.Input, GlAccount.IdCountry));
                spUpdate.AddParameter(new DBParameter("@Account", DbType.String, ParameterDirection.Input, GlAccount.Account));
                spUpdate.AddParameter(new DBParameter("@Name", DbType.String, ParameterDirection.Input, GlAccount.Name));
                spUpdate.AddParameter(new DBParameter("@IdCostType", DbType.Int32, ParameterDirection.Input, GlAccount.IdCostType));

                DBStoredProcedure spDelete = new DBStoredProcedure();
                spDelete.ProcedureName = "catDeleteGlAccount";
                spDelete.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, GlAccount.Id));
                spDelete.AddParameter(new DBParameter("@IdCountry", DbType.Int32, ParameterDirection.Input, GlAccount.IdCountry));

                this.AddStoredProcedure("InsertObject", spInsert);
                this.AddStoredProcedure("UpdateObject", spUpdate);
                this.AddStoredProcedure("DeleteObject", spDelete);

                DBStoredProcedure spSelect = new DBStoredProcedure();
                spSelect.ProcedureName = "catSelectGlAccount";
                spSelect.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, GlAccount.Id));
                spSelect.AddParameter(new DBParameter("@IdCountry", DbType.Int32, ParameterDirection.Input, GlAccount.IdCountry));
                this.AddStoredProcedure("SelectObject", spSelect);
            }
        }
        public int DeleteGlAccountTest(IGlAccount glAccount)
        {
            int rowCount = dbEntity.DeleteObject(glAccount);

            return(rowCount);
        }
 public int InsertGlAccountTest(IGlAccount glAccount)
 {
     glAccount.Id = dbEntity.InsertObject(glAccount);
     return(glAccount.Id);
 }