public void VerifyProjectType() { IProjectType projectType = BusinessObjectInitializer.CreateProjectType(); Random random = new Random(); projectType.Type = DATestUtils.GenerateString(20, true, false); projectType.Rank = random.Next(100000, 200000); int newId = InsertProjectTypeTest(projectType); Assert.Greater(newId, 0); int rowsAffected = UpdateProjectTypeTest(projectType); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectProjectTypeTest(projectType).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Type", "Rank", "Id" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteProjectTypeTest(projectType); Assert.AreEqual(1, rowCount); }
public void VerifyRegion() { IRegion region = BusinessObjectInitializer.CreateRegion(); Random random = new Random(); region.Name = DATestUtils.GenerateString(30, true, false); region.Code = DATestUtils.GenerateString(8, true, true); region.Rank = random.Next(100000, 200000); int newId = InsertRegionTest(region); Assert.Greater(newId, 0); int rowsUpdated = UpdateRegionTest(region); Assert.AreEqual(1, rowsUpdated); DataTable resultTable = SelectRegionTest(region).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Code", "Name", "Rank", "Id" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteRegionTest(region); Assert.AreEqual(1, rowCount); }
public void VerifyProjectPhase() { Random random = new Random(); IProjectPhase projectPhase = BusinessObjectInitializer.CreateProjectPhase(); projectPhase.Name = DATestUtils.GenerateString(50, true, false); projectPhase.Code = DATestUtils.GenerateString(10, true, true); int newId = InsertProjectPhaseTest(projectPhase); Assert.Greater(newId, 0); int rowsAffected = UpdateProjectPhaseTest(projectPhase); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectProjectPhaseTest(projectPhase).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Id", "Code", "Name" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteProjectPhaseTest(projectPhase); Assert.AreEqual(1, rowCount); }
public void VerifyDepartment() { Random random = new Random(); IDepartment department = BusinessObjectInitializer.CreateDepartment(); department.Name = DATestUtils.GenerateString(30, true, false); department.IdFunction = random.Next(1, 5); department.Rank = random.Next(100000, 200000); int newId = InsertDepartmentTest(department); Assert.Greater(newId, 0); int rowsAffected = UpdateDepartmentTest(department); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectDepartmentTest(department).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Name", "FunctionName", "Rank", "Id", "IdFunction", }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteDepartmentTest(department); Assert.AreEqual(1, rowCount); }
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 VerifyWorkPackage() { Random random = new Random(); IWorkPackage workPackage = BusinessObjectInitializer.CreateWorkPackage(); workPackage.IdProject = random.Next(1, 2); workPackage.IdPhase = random.Next(1, 9); workPackage.Code = DATestUtils.GenerateString(3, true, true); workPackage.Name = DATestUtils.GenerateString(30, true, false); workPackage.Rank = random.Next(1, 100); workPackage.IsActive = true; workPackage.StartYearMonth = DATestUtils.DEFAULT_YEAR_MONTH; workPackage.EndYearMonth = DATestUtils.DEFAULT_YEAR_MONTH; workPackage.LastUpdate = DateTime.Today; workPackage.IdLastUserUpdate = DATestUtils.DEFAULT_ASSOCIATE; int newId = InsertWorkPackageTest(workPackage); Assert.Greater(newId, 0); int rowsAffected = UpdateWorkPackageTest(workPackage); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectWorkPackageTest(workPackage).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "ProjectPhase", "ProjectCode", "Code", "Name", "Rank", "IsActive", "StartYearMonth", "EndYearMonth", "LastUpdate", "LastUserUpdate", "IsProgramManager", "ProjectName", "IdLastUserUpdate", "Id", "IdPhase", "IdProject", "IdProjectFunction" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteWorkPackageTest(workPackage); Assert.AreEqual(1, rowCount); }
public void VerifyFunction() { Random random = new Random(); IFunction function = BusinessObjectInitializer.CreateFunction(); function.Name = DATestUtils.GenerateString(30, true, false); function.Id = random.Next(1, 10); DataTable resultTable = SelectFunctionTest(function).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Id", "Name" }); DATestUtils.CheckTableStructure(resultTable, columns); }
public void VerifyAssociate() { IAssociate associate = BusinessObjectInitializer.CreateAssociate(); Random random = new Random(); associate.IdCountry = random.Next(1, 3); associate.Name = DATestUtils.GenerateString(50, true, false); associate.InergyLogin = DATestUtils.GenerateString(50, true, false); associate.EmployeeNumber = DATestUtils.GenerateString(15, true, false); associate.IsActive = true; associate.PercentageFullTime = random.Next(1, 100); associate.IsSubContractor = true; int newId = InsertAssociateTest(associate); //Verifies that the id returned by the insert method is greater than 1 Assert.Greater(newId, 0); int rowsAffected = UpdateAssociateTest(associate); //Verifies that one and only one row is affected by the update Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectAssociateTest(associate).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "CountryName", "EmployeeNumber", "Name", "InergyLogin", "IsActive", "PercentageFullTime", "IsSubContractor", "Id", "IdCountry" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteAssociateTest(associate); Assert.AreEqual(1, rowCount); }
public void VerifyOwnerType() { Random random = new Random(); IOwnerType ownerType = BusinessObjectInitializer.CreateOwnerType(); DBGenericEntity dbOwnerTypeEntity = new DBOwnerType(connManager); ownerType.Name = DATestUtils.GenerateString(50, true, false); ownerType.Id = random.Next(1, 5); DataTable resultTable = SelectOwnerTypeTest(ownerType).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Id", "Name" }); DATestUtils.CheckTableStructure(resultTable, columns); }
public void VerifyCostIncomeType() { Random random = new Random(); ICostIncomeType costIncomeType = BusinessObjectInitializer.CreateCostIncomeType(); costIncomeType.Name = DATestUtils.GenerateString(30, true, false); costIncomeType.Id = random.Next(1, 10); DataTable resultTable = SelectCostIncomeTypeTest(costIncomeType).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Id", "Name", "DefaultAccount" }); DATestUtils.CheckTableStructure(resultTable, columns); }
public void VerifyCurrency() { ICurrency currency = BusinessObjectInitializer.CreateCurrency(); Random random = new Random(); currency.Name = DATestUtils.GenerateString(30, true, false); //There are already currencies with id's from 1 to 12 in the database from the initialization script currency.Id = random.Next(1, 12); DataTable resultTable = SelectCurrencyTest(currency).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Id", "Code", "Name" }); DATestUtils.CheckTableStructure(resultTable, columns); }
public void VerifyCostCenter() { Random random = new Random(); ICostCenter costCenter = BusinessObjectInitializer.CreateCostCenter(); costCenter.Name = DATestUtils.GenerateString(50, true, false); costCenter.Code = DATestUtils.GenerateString(10, true, true); costCenter.IdDepartment = random.Next(1, 1); costCenter.IdInergyLocation = random.Next(1, 2); costCenter.IsActive = true; int newId = InsertCostCenterTest(costCenter); Assert.Greater(newId, 0); int rowsAffected = UpdateCostCenterTest(costCenter); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectCostCenterTest(costCenter).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "InergyLocation", "Code", "Name", "IsActive", "DepartmentName", "FunctionName", "Id", "IdInergyLocation", "IdDepartment", "IdFunction" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteCostCenterTest(costCenter); Assert.AreEqual(1, rowCount); }
public void VerifyProgram() { Random random = new Random(); IProgram program = BusinessObjectInitializer.CreateProgram(); program.Name = DATestUtils.GenerateString(50, true, false); program.Code = DATestUtils.GenerateString(10, true, true); program.IdOwner = random.Next(1, 3); program.Rank = random.Next(100000, 200000); int newId = InsertProgramTest(program); Assert.Greater(newId, 0); int rowsAffected = UpdateProgramTest(program); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectProgramTest(program).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Code", "Name", "OwnerName", "OwnerType", "IsActive", "Rank", "Id", "IdOwner", "IdOwnerType" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteProgramTest(program); 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); }
public void VerifyInitialBudget() { IInitialBudget initialBudget = BusinessObjectInitializer.CreateInitialBudget(); ICostCenter costCenter = BusinessObjectInitializer.CreateCostCenter(); IWorkPackage workPackage = BusinessObjectInitializer.CreateWorkPackage(); IProject project = BusinessObjectInitializer.CreateProject(); IProjectCoreTeamMember coreTeamMembers = BusinessObjectInitializer.CreateProjectCoreTeamMember(); DBInitialBudget dbInitialBudget = new DBInitialBudget(connManager); DBGenericEntity dbCostCenterEntity = new DBCostCenter(connManager); DBGenericEntity dbWorkPackageEntity = new DBWorkPackage(connManager); DBGenericEntity dbProjectEntity = new DBProject(connManager); DBProjectCoreTeamMember dbCoreteamMember = new DBProjectCoreTeamMember(connManager); Random random = new Random(); initialBudget.IdAssociate = DATestUtils.DEFAULT_ASSOCIATE; initialBudget.IdPhase = random.Next(1, 9); costCenter.Id = random.Next(1000, 2000); costCenter.Name = DATestUtils.GenerateString(50, true, false); costCenter.Code = DATestUtils.GenerateString(10, true, true); costCenter.IdDepartment = random.Next(1, 1); costCenter.IdInergyLocation = random.Next(1, 2); costCenter.IsActive = true; workPackage.IdPhase = initialBudget.IdPhase; workPackage.Code = DATestUtils.GenerateString(3, true, true); workPackage.Name = DATestUtils.GenerateString(30, true, false); workPackage.Rank = random.Next(1, 100); workPackage.IsActive = true; workPackage.StartYearMonth = random.Next(2000, 2079) * 100 + random.Next(1, 12); workPackage.EndYearMonth = random.Next(2000, 2079) * 100 + random.Next(1, 12); workPackage.LastUpdate = DateTime.Today; workPackage.IdLastUserUpdate = DATestUtils.DEFAULT_ASSOCIATE; project.Name = DATestUtils.GenerateString(50, true, false); project.Code = DATestUtils.GenerateString(10, true, true); project.IdProgram = random.Next(1, 2); project.IdProjectType = random.Next(1, 2); project.IsActive = true; initialBudget.Sales = random.Next(50000, 1000000); initialBudget.TotalHours = random.Next(1, 100); initialBudget.ValuedHours = random.Next(1, 100); initialBudget.YearMonth = DATestUtils.DEFAULT_YEAR_MONTH; int newId = InsertCostCenterTest(costCenter, dbCostCenterEntity); //Verifies that the id returned by the insert method is greater than 0 Assert.Greater(newId, 0); initialBudget.IdCostCenter = newId; newId = InsertProjectTest(project, dbProjectEntity); //Verifies that the id returned by the insert method is greater than 0 Assert.Greater(newId, 0); initialBudget.IdProject = newId; workPackage.IdProject = initialBudget.IdProject; coreTeamMembers.IdProject = initialBudget.IdProject; newId = InsertWorkPackageTest(workPackage, dbWorkPackageEntity); //Verifies that the id returned by the insert method is greater than 0 Assert.Greater(newId, 0); initialBudget.IdWP = newId; InsertInitialBudgetMasterTest(initialBudget, dbInitialBudget); coreTeamMembers.IdAssociate = DATestUtils.DEFAULT_ASSOCIATE; coreTeamMembers.IdFunction = DATestUtils.DEFAULT_PROJECT_FUNCTION; //verify if have core team member DataTable dsCoreMember = SelectProjectCoreTeamMemberTest(coreTeamMembers, dbCoreteamMember).Tables[0]; if (dsCoreMember.Rows.Count == 0) { int IdCoreteammember = InsertProjectCoreTeamMemberTest(coreTeamMembers, dbCoreteamMember); } InsertInitialBudgetTest(initialBudget, dbInitialBudget); UpdateInitialBudgetTest(initialBudget, dbInitialBudget); DBWPPreselection tempTable = new DBWPPreselection(connManager); tempTable.BulkInsert("CREATE TABLE #BUDGET_PRESELECTION_TEMP (IdProject INT NOT NULL, IdPhase INT NOT NULL, IdWP INT NOT NULL)"); tempTable.BulkInsert("INSERT INTO #BUDGET_PRESELECTION_TEMP (IdProject,IdPhase,IdWP) VALUES (" + initialBudget.IdProject.ToString() + "," + initialBudget.IdPhase.ToString() + "," + initialBudget.IdWP.ToString() + ")"); DataSet InitialBudgetDS = SelectInitialBudgetTest(initialBudget, dbInitialBudget); //Verifies that the table is not null DataTable tableVerifyPhases = InitialBudgetDS.Tables[0]; DataTable tableVerifyWorkPackages = InitialBudgetDS.Tables[1]; DataTable tableVerifyCostCenters = InitialBudgetDS.Tables[2]; Assert.IsNotNull(tableVerifyPhases, "The table returned should not be null"); Assert.IsNotNull(tableVerifyWorkPackages, "The table returned should not be null"); Assert.IsNotNull(tableVerifyCostCenters, "The table returned should not be null"); //Verifies that the first table is not null Assert.IsNotNull(tableVerifyPhases, "The table returned should not be null"); //Verifies that the table returns the correcty columns DATestUtils.CheckColumn(tableVerifyPhases, 0, "IdProject"); DATestUtils.CheckColumn(tableVerifyPhases, 1, "IdPhase"); DATestUtils.CheckColumn(tableVerifyPhases, 2, "PhaseName"); DATestUtils.CheckColumn(tableVerifyPhases, 3, "TotalHours"); DATestUtils.CheckColumn(tableVerifyPhases, 4, "Averate"); DATestUtils.CheckColumn(tableVerifyPhases, 5, "ValuedHours"); DATestUtils.CheckColumn(tableVerifyPhases, 6, "OtherCosts"); DATestUtils.CheckColumn(tableVerifyPhases, 7, "Sales"); DATestUtils.CheckColumn(tableVerifyPhases, 8, "NetCosts"); //Verifies that the second table is not null Assert.IsNotNull(tableVerifyWorkPackages, "The table returned should not be null"); //Verifies that the table returns the correcty columns DATestUtils.CheckColumn(tableVerifyWorkPackages, 0, "IdProject"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 1, "IdPhase"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 2, "IdWP"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 3, "WPName"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 4, "StartYearMonth"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 5, "EndYearMonth"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 6, "TotalHours"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 7, "Averate"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 8, "ValuedHours"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 9, "OtherCosts"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 10, "Sales"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 11, "NetCosts"); //Verifies that the third table is not null Assert.IsNotNull(tableVerifyWorkPackages, "The table returned should not be null"); //Verifies that the table returns the correcty columns DATestUtils.CheckColumn(tableVerifyCostCenters, 0, "IdProject"); DATestUtils.CheckColumn(tableVerifyCostCenters, 1, "IdPhase"); DATestUtils.CheckColumn(tableVerifyCostCenters, 2, "IdWP"); DATestUtils.CheckColumn(tableVerifyCostCenters, 3, "IdCostCenter"); DATestUtils.CheckColumn(tableVerifyCostCenters, 4, "CostCenterName"); DATestUtils.CheckColumn(tableVerifyCostCenters, 5, "TotalHours"); DATestUtils.CheckColumn(tableVerifyCostCenters, 6, "Averate"); DATestUtils.CheckColumn(tableVerifyCostCenters, 7, "ValuedHours"); DATestUtils.CheckColumn(tableVerifyCostCenters, 8, "OtherCosts"); DATestUtils.CheckColumn(tableVerifyCostCenters, 9, "Sales"); DATestUtils.CheckColumn(tableVerifyCostCenters, 10, "NetCosts"); DATestUtils.CheckColumn(tableVerifyCostCenters, 11, "IdCurrency"); DATestUtils.CheckColumn(tableVerifyCostCenters, 12, "CurrencyCode"); DeleteInitialBudgetTest(initialBudget, dbInitialBudget); int rowCount = DeleteCostCenterTest(costCenter, dbCostCenterEntity); //Verifies that one and only one row is affected by the delete Assert.AreEqual(1, rowCount); rowCount = DeleteWorkPackageTest(workPackage, dbWorkPackageEntity); //Verifies that one and only one row is affected by the delete Assert.AreEqual(1, rowCount); //Verifies that one and only one row is affected by the delete rowCount = DeleteProjectCoreTeamMemberTest(coreTeamMembers, dbCoreteamMember); Assert.AreEqual(1, rowCount); rowCount = DeleteProjectTest(project, dbProjectEntity); //Verifies that one and only one row is affected by the delete Assert.AreEqual(1, rowCount); }