Esempio n. 1
0
        public Order CreateExampleOrderWith(DateTime orderedDate) {
            Customer orderedBy = new Customer("Acme Anvil");
            Order order = new Order(orderedBy);
            order.OrderDate = orderedDate;

            return order;
        }
        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);
        }
        public void CannotHaveValidCustomerWithoutCompanyName() {
            // Register the IValidator service
            ServiceLocatorInitializer.Init();

            Customer customer = new Customer();
            customer.IsValid().ShouldBeFalse();

            customer.CompanyName = "Acme";
            customer.IsValid().ShouldBeTrue();
        }
        private List<Customer> CreateCustomers() {
            List<Customer> customers = new List<Customer>();

            Customer customer = new Customer("Acme Anvil");
            EntityIdSetter.SetIdOf(customer, "abcde");
            customers.Add(new Customer("Acme Anvil"));
            customers.Add(new Customer("Road Runner Industries"));

            return customers;
        }
        public void CanCreateCustomer() {
            Customer customer = new Customer("Acme Anvil");
            customer.CompanyName.ShouldEqual("Acme Anvil");

            customer.CompanyName = "Acme 2";
            customer.CompanyName.ShouldEqual("Acme 2");

            customer.ContactName.ShouldBeNull();
            customer.ContactName = "Billy";
            customer.ContactName.ShouldEqual("Billy");
        }
Esempio n. 7
0
        public Order(Customer orderedBy) {
            Check.Require(orderedBy != null, "orderedBy may not be null");

            OrderedBy = orderedBy;
        }