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); }