public void UpdateMethodOK() { clsCustomerCollection AllCustomers = new clsCustomerCollection(); clsCustomer TestItem = new clsCustomer(); Int32 PrimaryKey = 0; TestItem.Name = "John Smith"; TestItem.EmailAddress = "*****@*****.**"; TestItem.Address = "Flat 10, Charles street, Leicester"; TestItem.Password = "******"; TestItem.isEmailConfirmed = true; TestItem.LoyaltyPoints = 10.5; TestItem.CreatedAt = DateTime.Now.Date; AllCustomers.ThisCustomer = TestItem; PrimaryKey = AllCustomers.Add(); TestItem.CustomerId = PrimaryKey; // Modify data TestItem.Name = "Johnny Smith"; TestItem.EmailAddress = "*****@*****.**"; TestItem.Address = "Flat 21, Charles street, Leicester"; TestItem.Password = "******"; TestItem.isEmailConfirmed = false; TestItem.LoyaltyPoints = 12.5; TestItem.CreatedAt = DateTime.Now.Date; AllCustomers.ThisCustomer = TestItem; AllCustomers.Update(); AllCustomers.ThisCustomer.Find(PrimaryKey); Assert.AreEqual(AllCustomers.ThisCustomer, TestItem); }
public void UpdateMethodOK() { clsCustomerCollection allCustomers = new clsCustomerCollection(); clsCustomer TestItem = new clsCustomer(); Int32 PrimaryKey = 0; TestItem.Active = true; TestItem.CustomerId = 4; TestItem.Name = "Zeynep Tugce"; TestItem.CustomerRegisteredDate = DateTime.Now.Date; TestItem.ProductId = 40; TestItem.Point = 0; allCustomers.ThisCustomer = TestItem; PrimaryKey = allCustomers.Update(); TestItem.CustomerId = PrimaryKey; allCustomers.ThisCustomer.Find(PrimaryKey); Assert.AreEqual(allCustomers.ThisCustomer, TestItem); }
public void UpdateMethodOK() { clsCustomerCollection AllCustomers = new clsCustomerCollection(); //create the test customer clsCustomer TestCustomer = new clsCustomer(); Int32 PrimaryKey = 0; //set properties TestCustomer.Name = "a"; TestCustomer.Address = "ad"; TestCustomer.Postcode = "AA111BB"; TestCustomer.DoB = DateTime.Now.Date; TestCustomer.GdprRequest = true; AllCustomers.ThisCustomer = TestCustomer; //add customer to key PrimaryKey = AllCustomers.Add(); //set key TestCustomer.CustomerId = PrimaryKey; //update test customer TestCustomer.Name = "Test Son"; TestCustomer.Address = "Some Road"; TestCustomer.Postcode = "LE101NN"; TestCustomer.DoB = DateTime.Now.Date; TestCustomer.GdprRequest = false; //set customer with new data AllCustomers.ThisCustomer = TestCustomer; AllCustomers.Update(); AllCustomers.ThisCustomer.Find(PrimaryKey); Assert.AreEqual(AllCustomers.ThisCustomer, TestCustomer); }
public void UpdateMethodOK() { //create an instance of the class we want to create clsCustomerCollection AllCustomers = new clsCustomerCollection(); //create the item of test data clsCustomer TestItem = new clsCustomer(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Active = true; TestItem.CustomerId = 1; TestItem.Username = "******"; TestItem.DateAdded = DateTime.Now.Date; TestItem.Address = "an address"; TestItem.Password = "******"; //set ThisCustomer to the test data AllCustomers.ThisCustomer = TestItem; //add the record PrimaryKey = AllCustomers.Add(); //set the primary key of the test data TestItem.CustomerId = PrimaryKey; //modify the test data TestItem.Active = false; TestItem.CustomerId = 3; TestItem.Username = "******"; TestItem.DateAdded = DateTime.Now.Date; TestItem.Address = "an address2"; TestItem.Password = "******"; //set the record based on the new test data AllCustomers.ThisCustomer = TestItem; //update the record AllCustomers.Update(); //find the record AllCustomers.ThisCustomer.Find(PrimaryKey); //test to see ThisCustomer matches the test data Assert.AreEqual(AllCustomers.ThisCustomer, TestItem); }