public void Tables_CustomerAddressTables_RelationshipTest() { BaseTableAdapter tableAdapter = new GenderTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; Tables tables = new Tables(); tableAdapter.Fill(tables.GenderDataTable); tableAdapter = new ApppTprTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.ApppDataTable); tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.CustomerDataTable); tableAdapter = new AdminDivisionTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.AdminDivisionDataTable); tableAdapter = new TypeStreetTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.TypeStreetDataTable); tableAdapter = new AddressTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.AddressDataTable); Assert.IsTrue(tables.AddressDataTable.Rows.Count > 0); }
public void Tables_CustomerRegisterTables_RelationshipTest() { BaseTableAdapter tableAdapter = new GenderTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; Tables tables = new Tables(); tableAdapter.Fill(tables.GenderDataTable); tableAdapter = new ApppTprTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.ApppDataTable); tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.CustomerDataTable); tableAdapter = new RegisterTypeTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.RegisterTypeDataTable); tableAdapter = new LandTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.LandDataTable); tableAdapter = new WhyDeRegisterTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.WhyDeRegisterDataTable); tableAdapter = new RegisterTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.RegisterDataTable); Assert.IsTrue(tables.RegisterDataTable.Rows.Count > 1); }
public void Tables_CustomerInvalidTables_RelationshipTest() { BaseTableAdapter tableAdapter = new GenderTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; Tables tables = new Tables(); tableAdapter.Fill(tables.GenderDataTable); tableAdapter = new ApppTprTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.ApppDataTable); tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.CustomerDataTable); tableAdapter = new BenefitsCategoryTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.BenefitsDataTable); tableAdapter = new ChiperReceptTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.ChiperReceptDataTable); tableAdapter = new DisabilityGroupTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.DisabilityGroupDataTable); tableAdapter = new InvalidTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.InvalidDataTable); Assert.IsTrue(tables.InvalidDataTable.Rows.Count > 1); }
public void Tables_AddNewCustomerAndAddressTest() { SqlConnection connection = ConnectionManager.Connection; connection.Open(); Tables tables = new Tables(); BaseTableAdapter tableAdapter = new GenderTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Fill(tables.GenderDataTable); tableAdapter = new ApppTprTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Fill(tables.ApppDataTable); tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Fill(tables.CustomerDataTable); tableAdapter = new AdminDivisionTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Fill(tables.AdminDivisionDataTable); tableAdapter = new TypeStreetTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Fill(tables.TypeStreetDataTable); tableAdapter = new AddressTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Fill(tables.AddressDataTable); DataRow newRow = tables.CustomerDataTable.NewRow(); newRow["MedCard"] = 123; newRow["CodeCustomer"] = 321; newRow["LastName"] = "Bogodur"; newRow["FirstName"] = "Ivan"; newRow["MiddleName"] = "Bogodurovich"; newRow["Birthday"] = new DateTime(1970, 1, 1); newRow["Arch"] = false; newRow["APPPTPRID"] = tables.ApppDataTable.Rows[0]["APPPTPRID"]; newRow["GenderID"] = tables.GenderDataTable.Rows[0]["GenderID"]; tables.CustomerDataTable.Rows.Add(newRow); int newCustomerId = (int)newRow["CustomerID"]; newRow = tables.AddressDataTable.NewRow(); newRow["City"] = "Slavyansk"; newRow["AdminDivisionID"] = tables.AdminDivisionDataTable.Rows[0]["AdminDivisionID"];; newRow["NameStreet"] = "Lenina"; newRow["NumberHouse"] = "57"; newRow["NumberApartment"] = "37"; newRow["CustomerID"] = newCustomerId; tables.AddressDataTable.Rows.Add(newRow); tables.DispancerDataSet.AcceptChanges(); var ds = tables.DispancerDataSet.GetChanges(); int count = 0; if (ds != null) { count = ds.Tables.Count; } Assert.IsTrue(count == 0); }
public void FillTest() { ConnectionManager.ConnectionManager.SetConnection("Катя", "1"); conn = ConnectionManager.ConnectionManager.Connection; // conn.Open(); GenderTableAdapter gender = new GenderTableAdapter(); gender.Connection = conn; int count = gender.Fill(new DataTable("")); Assert.IsTrue(count > 0); }
public void Tables_CustomerInvalidTables_Relationship_DeleteCascadTest() { ConnectionManager.SetConnection("Supervisor", "admin"); BaseTableAdapter tableAdapter = new GenderTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; Tables tables = new Tables(); tableAdapter.Fill(tables.GenderDataTable); tableAdapter = new ApppTprTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.ApppDataTable); tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.CustomerDataTable); tableAdapter = new BenefitsCategoryTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.BenefitsDataTable); tableAdapter = new ChiperReceptTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.ChiperReceptDataTable); tableAdapter = new DisabilityGroupTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.DisabilityGroupDataTable); tableAdapter = new InvalidTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.InvalidDataTable); int countRows = tables.InvalidDataTable.Rows.Count; int customerId = Int32.Parse(tables.InvalidDataTable.Rows[tables.InvalidDataTable.Rows.Count - 1]["CustomerID"].ToString()); for (int i = 0; i < tables.CustomerDataTable.Rows.Count; i++) { if (Int32.Parse(tables.CustomerDataTable.Rows[i][0].ToString()) == customerId) { tables.CustomerDataTable.Rows[i].Delete(); break; } } tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; ((UpdateBaseTableAdapter)tableAdapter).Update(tables.CustomerDataTable); tableAdapter = new InvalidTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.InvalidDataTable); Assert.IsTrue(countRows - tables.InvalidDataTable.Rows.Count >= 1); }
public void Tables_CustomerRegisterTables_Relationship_DeleteCascadTest() { ConnectionManager.SetConnection("Supervisor", "admin"); BaseTableAdapter tableAdapter = new GenderTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; Tables tables = new Tables(); tableAdapter.Fill(tables.GenderDataTable); tableAdapter = new ApppTprTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.ApppDataTable); tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.CustomerDataTable); tableAdapter = new RegisterTypeTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.RegisterTypeDataTable); tableAdapter = new LandTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.LandDataTable); tableAdapter = new WhyDeRegisterTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.WhyDeRegisterDataTable); tableAdapter = new RegisterTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.RegisterDataTable); int countRows = tables.RegisterDataTable.Rows.Count; int customerId = Int32.Parse(tables.RegisterDataTable.Rows[tables.RegisterDataTable.Rows.Count - 1]["CustomerID"].ToString()); for (int i = 0; i < tables.CustomerDataTable.Rows.Count; i++) { if (Int32.Parse(tables.CustomerDataTable.Rows[i][0].ToString()) == customerId) { tables.CustomerDataTable.Rows[i].Delete(); break; } } tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; ((UpdateBaseTableAdapter)tableAdapter).Update(tables.CustomerDataTable); tableAdapter = new RegisterTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.RegisterDataTable); Assert.IsTrue(countRows - tables.RegisterDataTable.Rows.Count >= 1); }
public void Tables_CustomerAddressTables_TransactionTest() { SqlConnection connection = ConnectionManager.Connection; connection.Open(); SqlTransaction transaction = connection.BeginTransaction(); BaseTableAdapter tableAdapter = new GenderTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Transaction = transaction; Tables tables = new Tables(); tableAdapter.Fill(tables.GenderDataTable); tableAdapter = new ApppTprTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Transaction = transaction; tableAdapter.Fill(tables.ApppDataTable); tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Transaction = transaction; tableAdapter.Fill(tables.CustomerDataTable); tableAdapter = new AdminDivisionTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Transaction = transaction; tableAdapter.Fill(tables.AdminDivisionDataTable); tableAdapter = new TypeStreetTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Transaction = transaction; tableAdapter.Fill(tables.TypeStreetDataTable); tableAdapter = new AddressTableAdapter(); tableAdapter.Connection = connection; tableAdapter.Transaction = transaction; tableAdapter.Fill(tables.AddressDataTable); transaction.Commit(); Assert.IsTrue(tables.AddressDataTable.Rows.Count > 0); }
public void Tables_InvalidBenefitsTables_Relationship_DeleteCascadTest() { ConnectionManager.SetConnection("Supervisor", "admin"); BaseTableAdapter tableAdapter = new GenderTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; Tables tables = new Tables(); tableAdapter.Fill(tables.GenderDataTable); tableAdapter = new ApppTprTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.ApppDataTable); tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.CustomerDataTable); tableAdapter = new BenefitsCategoryTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.BenefitsDataTable); tableAdapter = new ChiperReceptTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.ChiperReceptDataTable); tableAdapter = new DisabilityGroupTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.DisabilityGroupDataTable); tableAdapter = new InvalidTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.InvalidDataTable); tableAdapter = new InvalidBenefitsCategoryTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.InvalidBenefitsDataTable); int countRows = tables.InvalidBenefitsDataTable.Rows.Count; bool isRow = false; for (int i = 0; i < tables.InvalidBenefitsDataTable.Rows.Count; i++) { int invalidId = Int32.Parse(tables.InvalidBenefitsDataTable.Rows[tables.InvalidBenefitsDataTable.Rows.Count - 1]["InvID"].ToString()); Debug.WriteLine("InvID " + invalidId); int customerId = -10; for (int j = 0; j < tables.InvalidDataTable.Rows.Count; j++) { if (Int32.Parse(tables.InvalidDataTable.Rows[j][0].ToString()) == invalidId) { customerId = Int32.Parse(tables.InvalidDataTable.Rows[j]["CustomerID"].ToString()); isRow = true; Debug.WriteLine("CustomerID " + customerId); break; } } if (isRow) { for (int z = 0; z < tables.CustomerDataTable.Rows.Count; z++) { if (Int32.Parse(tables.CustomerDataTable.Rows[z][0].ToString()) == customerId) { tables.CustomerDataTable.Rows[z].Delete(); break; } } } if (isRow) { break; } } tableAdapter = new CustomerTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; ((UpdateBaseTableAdapter)tableAdapter).Update(tables.CustomerDataTable); tables.InvalidBenefitsDataTable.Clear(); tableAdapter = new InvalidTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.InvalidDataTable); tableAdapter = new InvalidBenefitsCategoryTableAdapter(); tableAdapter.Connection = ConnectionManager.Connection; tableAdapter.Fill(tables.InvalidBenefitsDataTable); Assert.IsTrue(countRows - tables.InvalidBenefitsDataTable.Rows.Count >= 1); }