public void VerifyProjectFunction() { Random random = new Random(); DBProjectFunction dbProjectFunctionEntity = new DBProjectFunction(connManager); IProjectFunction projectFunction = BusinessObjectInitializer.CreateProjectFunction(); DataTable tableVerify = SelectProjectFunctionTest(projectFunction, dbProjectFunctionEntity).Tables[0]; //Verifies that the table is not null Assert.IsNotNull(tableVerify, "The table returned should not be null"); //Verifies that the table returns the correcty columns DATestUtils.CheckColumn(tableVerify, 0, "Id"); DATestUtils.CheckColumn(tableVerify, 1, "Name"); }
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 VerifyProjectCoreTeamMember() { Random random = new Random(); DBProjectCoreTeamMember dbProjectCoreTeamMemberEntity = new DBProjectCoreTeamMember(connManager); IProjectCoreTeamMember projectCoreTeamMember = BusinessObjectInitializer.CreateProjectCoreTeamMember(); projectCoreTeamMember.IdFunction = DATestUtils.DEFAULT_PROJECT_FUNCTION; projectCoreTeamMember.IdAssociate = DATestUtils.DEFAULT_ASSOCIATE; projectCoreTeamMember.IdProject = random.Next(1, 2); projectCoreTeamMember.IsActive = true; DataTable dtCoreTeamMembers = SelectProjectCoreTeamMemberTest(projectCoreTeamMember, dbProjectCoreTeamMemberEntity).Tables[0]; if (dtCoreTeamMembers.Rows.Count == 0) { int newId = InsertProjectCoreTeamMemberTest(projectCoreTeamMember, dbProjectCoreTeamMemberEntity); Assert.AreEqual(newId, 1); } int rowsAffected = UpdateProjectCoreTeamMemberTest(projectCoreTeamMember, dbProjectCoreTeamMemberEntity); Assert.AreEqual(1, rowsAffected); int rowCount = DeleteProjectCoreTeamMemberTest(projectCoreTeamMember, dbProjectCoreTeamMemberEntity); Assert.AreEqual(1, rowCount); DataTable tableVerify = SelectProjectCoreTeamMemberTest(projectCoreTeamMember, dbProjectCoreTeamMemberEntity).Tables[0]; //Verifies that the table is not null Assert.IsNotNull(tableVerify, "The table returned should not be null"); //Verifies that the table returns the correcty columns DATestUtils.CheckColumn(tableVerify, 0, "CoreTeamMemberName"); DATestUtils.CheckColumn(tableVerify, 1, "FunctionName"); DATestUtils.CheckColumn(tableVerify, 2, "Country"); DATestUtils.CheckColumn(tableVerify, 3, "LastUpdateDate"); DATestUtils.CheckColumn(tableVerify, 4, "IsActive"); DATestUtils.CheckColumn(tableVerify, 5, "IdProject"); DATestUtils.CheckColumn(tableVerify, 6, "IdAssociate"); DATestUtils.CheckColumn(tableVerify, 7, "IdFunction"); DATestUtils.CheckColumn(tableVerify, 8, "ProjectName"); }
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 VerifyProject() { Random random = new Random(); IProject project = BusinessObjectInitializer.CreateProject(); 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; int newId = InsertProjectTest(project); Assert.Greater(newId, 0); int rowsAffected = UpdateProjectTest(project); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectProjectTest(project).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Code", "Name", "ProgramCode", "ProjectType", "IsActive", "ProgramName", "Id", "IdProgram", "IdProjectType" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteProjectTest(project); Assert.AreEqual(1, rowCount); }
public void VerifyHourlyRate() { Random random = new Random(); IHourlyRate hourlyRate = BusinessObjectInitializer.CreateHourlyRate(); hourlyRate.YearMonth = random.Next(2010, 2079) * 100 + random.Next(1, 12); hourlyRate.IdCurrency = random.Next(1, 12); hourlyRate.IdCostCenter = random.Next(1, 3); hourlyRate.Value = DATestUtils.DEFAULT_DECIMAL_VALUE; int newId = InsertHourlyRateTest(hourlyRate); Assert.AreEqual(newId, 0); int rowsAffected = UpdateHourlyRateTest(hourlyRate); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectHourlyRateTest(hourlyRate).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "InergyLocationName", "CostCenterCode", "CurrencyName", "Value", "YearMonth", "CostCenterName", "IdInergyLocation", "IdCostCenter", "IdCurrency" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteHourlyRateTest(hourlyRate); 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 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 void VerifyOwner() { Random random = new Random(); IOwner owner = BusinessObjectInitializer.CreateOwner(); owner.Name = DATestUtils.GenerateString(30, true, false); owner.Code = DATestUtils.GenerateString(3, true, true); owner.IdOwnerType = random.Next(1, 5); owner.Rank = random.Next(100000, 200000); int newId = InsertOwnerTest(owner); Assert.Greater(newId, 0); int rowsAffected = UpdateOwnerTest(owner); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectOwnerTest(owner).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "Code", "Name", "OwnerType", "Rank", "Id", "IdOwnerType" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteOwnerTest(owner); 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); }