Beispiel #1
0
        public void CanUpdateCustomer()
        {
            // arrange
            IRepo <Customer>     customerRepo     = new MockContext <Customer>();
            IRepo <Car>          carRepo          = new MockContext <Car>();
            IRepo <Reservation>  reservationRepo  = new MockContext <Reservation>();
            IRepo <Location>     locationRepo     = new MockContext <Location>();
            IRepo <Model>        modelRepo        = new MockContext <Model>();
            IRepo <Manufacturer> manufacturerRepo = new MockContext <Manufacturer>();

            var customerFactory = new CustomerFactory();

            customerRepo.Insert(customerFactory.GetCustomer(1, 1, "1"));

            var controller = new CustomerController(carRepo, customerRepo, reservationRepo,
                                                    locationRepo, modelRepo, manufacturerRepo);


            var customer = customerFactory.GetQueryCustomer(1, 1, "c");

            customer.Customer = customerRepo.Collection().FirstOrDefault();

            // act
            controller.Update(customer);
            Customer c = customerRepo.Collection().FirstOrDefault();

            // assert
            Assert.IsNotNull(c);
            Assert.AreEqual(1, customerRepo.Collection().Count());
            Assert.AreEqual("c", c.Name);
        }