Here is an example of a Customer class in C# that includes methods for adding and deleting customers, as well as a unit test method for testing the add and delete methods:
public class Customer { // Fields for the customer's name and ID private string name; private int id; // Constructor for the Customer class public Customer(string name, int id) { this.name = name; this.id = id; } // Method for adding a customer public void AddCustomer() { // Code for adding a customer goes here } // Method for deleting a customer public void DeleteCustomer() { // Code for deleting a customer goes here } // Unit test method for testing the AddCustomer and DeleteCustomer methods [TestMethod] public void TestAddAndDeleteCustomer() { // Create a new Customer object Customer customer = new Customer("John Doe", 12345); // Add the customer customer.AddCustomer(); // Verify that the customer was added successfully // by checking the customer's name and ID Assert.AreEqual(customer.Name, "John Doe"); Assert.AreEqual(customer.ID, 12345); // Delete the customer customer.DeleteCustomer(); // Verify that the customer was deleted successfully // by checking the customer's name and ID Assert.AreEqual(customer.Name, null); Assert.AreEqual(customer.ID, 0); } }
Comments
Post a Comment