public void TestAddAndReadMethods() { // Arrange (initialize variables) var newCustomer = new Customer("Casey", "McDonough", CustomerType.Current); // Act (add newCustomer to the _customerList field using the Create method customerTester.CreateCustomer(newCustomer); // Assert (that the field of customers is not null, and that the count is greater than 0) var custList = customerTester.GetAllCustomers(); Assert.IsNotNull(custList, "Add failed."); // Also tests the Get/Read method to make sure it reads the field properly Assert.IsTrue(custList.Count > 0, "Add failed."); }
private void btnCreateCustomer_Click_1(object sender, EventArgs e) { Customer customer = new Customer(); if (textFieldFilled()) { customer.ContactName = txtContactName.Text; customer.ContactTitle = txtContactTitle.Text; customer.CompanyName = txtCompany.Text; customer.Address = txtAddress.Text; customer.Country = txtCountry.Text; customer.City = txtCity.Text; customer.Region = txtRegion.Text; customer.PostalCode = txtPostalCode.Text; customer.Phone = txtPhone.Text; customer.Fax = txtFax.Text; customer.CustomerID = GenerateID(customer); customerCRUD.CreateCustomer(customer); MessageBox.Show("Customer Added! ID = " + customer.CustomerID + "!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Please, fill the missing fields!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddNewCustomer() { var newCustomer = EnterCustomerDetails(); customerManipulator.CreateCustomer(newCustomer); }