public DataSet SelectInergyLocationTest(IInergyLocation inergyLocation) { DataSet tableVerify = new DataSet(); tableVerify = dbEntity.SelectObject(inergyLocation) as DataSet; return(tableVerify); }
protected override void InitializeObject(IGenericEntity ent) { if (ent is IInergyLocation) { IInergyLocation InergyLocation = (IInergyLocation)ent; DBStoredProcedure spInsert = new DBStoredProcedure(); spInsert.ProcedureName = "catInsertInergyLocation"; spInsert.AddParameter(new DBParameter("@IdCountry", DbType.Int32, ParameterDirection.Input, InergyLocation.IdCountry)); spInsert.AddParameter(new DBParameter("@Code", DbType.String, ParameterDirection.Input, InergyLocation.Code)); spInsert.AddParameter(new DBParameter("@Name", DbType.String, ParameterDirection.Input, InergyLocation.Name)); spInsert.AddParameter(new DBParameter("@Rank", DbType.Int32, ParameterDirection.Input, InergyLocation.Rank)); DBStoredProcedure spUpdate = new DBStoredProcedure(); spUpdate.ProcedureName = "catUpdateInergyLocation"; spUpdate.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, InergyLocation.Id)); spUpdate.AddParameter(new DBParameter("@IdCountry", DbType.Int32, ParameterDirection.Input, InergyLocation.IdCountry)); spUpdate.AddParameter(new DBParameter("@Code", DbType.String, ParameterDirection.Input, InergyLocation.Code)); spUpdate.AddParameter(new DBParameter("@Name", DbType.String, ParameterDirection.Input, InergyLocation.Name)); spUpdate.AddParameter(new DBParameter("@Rank", DbType.Int32, ParameterDirection.Input, InergyLocation.Rank)); DBStoredProcedure spDelete = new DBStoredProcedure(); spDelete.ProcedureName = "catDeleteInergyLocation"; spDelete.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, InergyLocation.Id)); this.AddStoredProcedure("InsertObject", spInsert); this.AddStoredProcedure("UpdateObject", spUpdate); this.AddStoredProcedure("DeleteObject", spDelete); DBStoredProcedure spSelect = new DBStoredProcedure(); spSelect.ProcedureName = "catSelectInergyLocation"; spSelect.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, InergyLocation.Id)); this.AddStoredProcedure("SelectObject", spSelect); //used in Annual Budget for selecting an Inergy Location when a country Id is provided DBStoredProcedure spSelectInergyLocation_Country = new DBStoredProcedure(); spSelectInergyLocation_Country.ProcedureName = "catSelectInergyLocation_Country"; spSelectInergyLocation_Country.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, InergyLocation.IdCountry)); this.AddStoredProcedure("SelectInergyLocation_Country", spSelectInergyLocation_Country); } }
public void VerifyInergyLocation() { Random random = new Random(); IInergyLocation inergyLocation = BusinessObjectInitializer.CreateInergyLocation(); inergyLocation.Name = DATestUtils.GenerateString(30, true, false); inergyLocation.Code = DATestUtils.GenerateString(3, true, true); inergyLocation.IdCountry = random.Next(1, 3); inergyLocation.Rank = random.Next(100000, 200000); int newId = InsertInergyLocationTest(inergyLocation); Assert.Greater(newId, 0); int rowsAffected = UpdateInergyLocationTest(inergyLocation); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectInergyLocationTest(inergyLocation).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Code", "Name", "CountryName", "Rank", "CurrencyName", "Id", "IdCountry", "IdCurrency" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteInergyLocationTest(inergyLocation); Assert.AreEqual(1, rowCount); }
public int DeleteInergyLocationTest(IInergyLocation inergyLocation) { int rowCount = dbEntity.DeleteObject(inergyLocation); return(rowCount); }
public int InsertInergyLocationTest(IInergyLocation inergyLocation) { inergyLocation.Id = dbEntity.InsertObject(inergyLocation); return(inergyLocation.Id); }