public ActionResult Create(string companyName, string assignedId) { Customer customer = new Customer(companyName); customer.SetAssignedIdTo(assignedId); customerRepository.Save(customer); return View(customer); }
public void CanCompareCustomers() { Customer customerA = new Customer("Acme"); Customer customerB = new Customer("Anvil"); customerA.ShouldNotEqual(null); customerA.ShouldNotEqual(customerB); customerA.SetAssignedIdTo("AAAAA"); customerB.SetAssignedIdTo("AAAAA"); // Even though the "business value signatures" are different, the persistent IDs // were the same. Call me crazy, but I put that much trust into persisted IDs. customerA.ShouldEqual(customerB); Customer customerC = new Customer("Acme"); // Since customerA has an ID but customerC doesn't, they won't be equal // even though their signatures are the same customerA.ShouldNotEqual(customerC); Customer customerD = new Customer("Acme"); // customerC and customerD are both transient and share the same signature customerC.ShouldEqual(customerD); }