private static void emptyTableContactType() { ContactTypeService contactTypeSrv = new ContactTypeService(); contactTypeSrv.emptyTable(); List<ContactTypeBO> contactTypes = contactTypeSrv.getAllFromTable(); Assert.AreEqual(0, contactTypes.Count(), string.Format("'ContactType' Table should be empty.")); }
//constructor creating page with pre-filled data from selected customer details public CustomerUpdateV(CustomerBO selectedCustomer, bool newCustomer) { InitializeComponent(); //determine, whether user want to add new customer, or update existing customer this._addingNewCustomer = newCustomer; this._selectedCustomer = selectedCustomer; //top part of the window is the same asd CustomerAddV, so the information is transferred txtCompanyName.Text = selectedCustomer.CompanyName; txtCompanyContactName.Text = selectedCustomer.ContactPerson; // filling ContactTypes combobox with respective values ContactTypeService contactTypeSrv = new ContactTypeService(); List<ContactTypeBO> contactTypes = contactTypeSrv.getAllFromTable(); cboxContacts.ItemsSource = contactTypes; // filling Contact list with respective values updateListContacts(); }
/// <remarks> /// Displays customer details and contacts if any customer is selected in table /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void listCustomers_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listCustomers.SelectedItem != null) { CustomerBO selectedCustomer = (CustomerBO)listCustomers.SelectedItem; lblCompanyName.Content = selectedCustomer.CompanyName; lblContactPerson.Content = selectedCustomer.ContactPerson; ContactService contactSrv = new ContactService(); List<ContactBO> customerContacts = contactSrv.getAllFromTableByCustomerID(selectedCustomer.CustomerID); ContactTypeService contactTypeSrv = new ContactTypeService(); //adding ContactType Name to ContactBO Obj. by ContactType ID foreach (ContactBO customerContact in customerContacts) { customerContact.ContactTypeName = contactTypeSrv.getNameById(customerContact.ContactTypeID); } listContacts.ItemsSource = customerContacts; } }
/// <remarks> /// if row selection in Customer contact table is changed, recpective data is stored to editable boxes /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void listContacts_SelectionChanged(object sender, SelectionChangedEventArgs e) { txtError.Content = ""; ContactBO listContact = (ContactBO)listContacts.SelectedItem; ContactTypeService contactTypeSrv = new ContactTypeService(); //It is called on add/modify contact on db also (not on user activity only) //So after new list update noone is selected. if (null != listContact) { // TODO: add selected ContactType to Combobox as "preselected" txtContactTypeValue.Text = listContact.Value; } }
/// <remarks> /// updates Customer Contact list after adding/updating contacts. /// </remarks> private void updateListContacts() { ContactTypeService contactTypeSrv = new ContactTypeService(); ContactService contactSrv = new ContactService(); List<ContactBO> customerContacts = contactSrv.getAllFromTableByCustomerID(_selectedCustomer.CustomerID); //adding ContactType Name to ContactBO Obj. by ContactType ID foreach (ContactBO customerContact in customerContacts) { customerContact.ContactTypeName = contactTypeSrv.getNameById(customerContact.ContactTypeID); } listContacts.ItemsSource = customerContacts; }
/// <summary> /// This method tests ContactType Table /// We test that minimum expected rows are exist /// and their values are correct /// </summary> public static void testContactTypesDataCorrectness() { ContactTypeService contactTypeSrv = new ContactTypeService(); List<ContactTypeBO> contactTypes = contactTypeSrv.getAllFromTable(); String expValueName1 = "skype"; bool isVerifiedValue1 = false; String expValueName2 = "phone"; bool isVerifiedValue2 = false; String expValueName3 = "email"; bool isVerifiedValue3 = false; foreach (var contactType in contactTypes) { if (expValueName1 == contactType.Name) { isVerifiedValue1 = true; } if (expValueName2 == contactType.Name) { isVerifiedValue2 = true; } if (expValueName3 == contactType.Name) { isVerifiedValue3 = true; } //debug info //string valjund = string.Format("{0} {1} ", contactType.ContactTypeID, contactType.Name); //Console.WriteLine(valjund); } Assert.AreEqual(true, isVerifiedValue1, string.Format("'{0}' Verification failed", expValueName1)); Assert.AreEqual(true, isVerifiedValue2, string.Format("'{0}' Verification failed", expValueName2)); Assert.AreEqual(true, isVerifiedValue3, string.Format("'{0}' Verification failed", expValueName3)); }
private static void fullFillContactTypeTable() { ContactTypeService contactTypeSrv = new ContactTypeService(); contactTypeSrv.addNew("skype", false);//TODO: take first from list contactTypeSrv.addNew("phone", true); contactTypeSrv.addNew("email", false); List<ContactTypeBO> contactTypes = contactTypeSrv.getAllFromTable(); Assert.AreNotEqual(0, contactTypes.Count(), string.Format("There should be values in 'ContactType' Table.")); }
private static void fullFillContactTable() { ContactTypeService contactTypeSrv = new ContactTypeService(); List<ContactTypeBO> contactTypes = contactTypeSrv.getAllFromTable(); Assert.AreNotEqual(0, contactTypes.Count(), string.Format("There should be values in 'ContactType' Table.")); int existingContactTypeID = contactTypes.ElementAt(0).ContactTypeID; CustomerService customerSrv = new CustomerService(); List<CustomerBO> customers = customerSrv.getAllFromTable(); Assert.AreNotEqual(0, customers.Count(), string.Format("There should be values in 'Customer' Table.")); int existingCustomerID = customers.ElementAt(0).CustomerID; //TODO: Verify that contact cannot be created before Customer (CustomerID foreign key) //TODO: Verify that contact cannot be created before ContactType (ContactTypeID foreign key) ContactService contactSrv = new ContactService(); contactSrv.addNew(existingCustomerID, existingContactTypeID, "val_skype", DateTime.Now);//TODO: take first from list contactSrv.addNew(existingCustomerID, existingContactTypeID, "val_mail", DateTime.Now); contactSrv.addNew(existingCustomerID, existingContactTypeID, "val_phone", DateTime.Now); List<ContactBO> contacts = contactSrv.getAllFromTable(); Assert.AreNotEqual(0, contacts.Count(), string.Format("There should be values in 'Contact' Table.")); }