Ejemplo n.º 1
0
 // Adds any employees that we pass in to the store that we pass in
 private void AddEmployeesToStore(Store store, params Employee[] employees)
 {
     foreach (var employee in employees)
     {
         store.AddEmployee(employee);
     }
 }
Ejemplo n.º 2
0
 public static void AddEmployeesToStore(Store store, params Employee[] employees)
 {
     foreach (var employee in employees)
     {
         store.AddEmployee(employee);
     }
 }
Ejemplo n.º 3
0
 public static void AddEmployeesToStore(Store store, params Employee[] employees)
 {
     foreach (var employee in employees)
     {
         store.AddEmployee(employee);
     }
 }
Ejemplo n.º 4
0
        void should_CRUD_employees_when_CRUD_a_store()
        {
            var store = new Store
            {
                Name = "Wonder's Store"
            };

            var employee = new Employee
            {
                FirstName = "Wonder",
                LastName  = "King",
                Store     = store
            };

            store.AddEmployee(employee);

            //create
            storeRepository.Create(store);

            //retreive from store
            Store retreivedStore = storeRepository.FindById(store.Id);

            Assert.Equal(store.Name, retreivedStore.Name);
            Assert.Equal(1, retreivedStore.Staff.Count);
            Assert.Equal(employee.FirstName, retreivedStore.Staff[0].FirstName);

            //retreive from employee
            Employee retreivedEmployee = employeeRepository.FindById(retreivedStore.Staff[0].Id);

            Assert.Equal(store.Name, retreivedEmployee.Store.Name);

            //update
            employee.LastName = "Kingggg";
            storeRepository.Update(store);
            Assert.Equal("Kingggg", store.Staff[0].LastName);

            //delete orhpen
            store.FireEmployee(employee);
            storeRepository.Update(store);
            Session.Flush();
            Store anotherRetreived = storeRepository.FindById(store.Id);

            Assert.Equal(0, anotherRetreived.Staff.Count);
            Assert.Equal(null, employeeRepository.FindById(employee.Id));


            //delete
            storeRepository.Delete(store);
            Assert.Null(employeeRepository.FindById(employee.Id));
        }
Ejemplo n.º 5
0
        void should_not_delete_employee_when_associate_with_a_store()
        {
            var store = new Store
            {
                Name = "Wonder's Store",
            };

            var employee = new Employee
            {
                FirstName = "Wonder",
                LastName  = "King",
                Store     = store
            };

            store.AddEmployee(employee);
            storeRepository.Create(store);
            Assert.Throws <ObjectDeletedException>(() => employeeRepository.Delete(employee));
        }
Ejemplo n.º 6
0
        void should_not_create_employee_when_associated_store_is_not_created()
        {
            var store = new Store
            {
                Name = "Wonder's Store",
            };

            var employee = new Employee
            {
                FirstName = "Wonder",
                LastName  = "King",
                Store     = store
            };

            store.AddEmployee(employee);
            Assert.Throws <TransientObjectException>(() => employeeRepository.Create(employee));
            Session.Clear();
        }