public void InitializeWithEmptyData()
        {
            using (FakeEmployeeContext ctx = new FakeEmployeeContext())
            {
                UnitOfWork unit = new UnitOfWork(ctx);
                ObservableCollection<DepartmentViewModel> departments = new ObservableCollection<DepartmentViewModel>();
                ObservableCollection<EmployeeViewModel> employees = new ObservableCollection<EmployeeViewModel>();
                EmployeeWorkspaceViewModel vm = new EmployeeWorkspaceViewModel(employees, departments, unit);

                Assert.AreSame(employees, vm.AllEmployees, "ViewModel should expose the same instance of the collection so that changes outside the ViewModel are reflected.");
                Assert.IsNull(vm.CurrentEmployee, "Current employee should not be set if there are no department.");
                Assert.IsNotNull(vm.AddEmployeeCommand, "AddEmployeeCommand should be initialized");
                Assert.IsNotNull(vm.DeleteEmployeeCommand, "DeleteEmployeeCommand should be initialized");
            }
        }
        /// <summary>
        /// Verifies addition of employee to workspace and unit of work
        /// </summary>
        /// <param name="unitOfWork">Context employee should get added to</param>
        /// <param name="vm">Workspace to add employee to</param>
        private static void TestAddEmployee(FakeEmployeeContext ctx, EmployeeWorkspaceViewModel vm)
        {
            List<EmployeeViewModel> originalEmployees = vm.AllEmployees.ToList();

            string lastProperty = null;
            vm.PropertyChanged += (sender, e) => { lastProperty = e.PropertyName; };

            Assert.IsTrue(vm.AddEmployeeCommand.CanExecute(null), "Add command should always be enabled.");
            vm.AddEmployeeCommand.Execute(null);

            Assert.AreEqual(originalEmployees.Count + 1, vm.AllEmployees.Count, "One new employee should have been added to the AllEmployees property.");
            Assert.IsFalse(originalEmployees.Contains(vm.CurrentEmployee), "The new employee should be selected.");
            Assert.IsNotNull(vm.CurrentEmployee, "The new employee should be selected.");
            Assert.AreEqual("CurrentEmployee", lastProperty, "CurrentEmployee should have raised a PropertyChanged.");
            Assert.IsTrue(ctx.IsObjectTracked(vm.CurrentEmployee.Model), "The new employee has not been added to the context.");
        }
        public void InitializeWithData()
        {
            Employee e1 = new Employee();
            Employee e2 = new Employee();

            Department d1 = new Department();
            Department d2 = new Department();

            using (FakeEmployeeContext ctx = new FakeEmployeeContext(new Employee[] { e1, e2 }, new Department[] { d1, d2 }))
            {
                UnitOfWork unit = new UnitOfWork(ctx);
                ObservableCollection<DepartmentViewModel> departments = new ObservableCollection<DepartmentViewModel>(ctx.Departments.Select(d => new DepartmentViewModel(d)));
                ObservableCollection<EmployeeViewModel> employees = new ObservableCollection<EmployeeViewModel>();
                foreach (var e in ctx.Employees)
                {
                    employees.Add(new EmployeeViewModel(e, employees, departments, unit));
                }

                EmployeeWorkspaceViewModel vm = new EmployeeWorkspaceViewModel(employees, departments, unit);

                Assert.IsNotNull(vm.CurrentEmployee, "Current employee should be set if there are departments.");
                Assert.AreSame(employees, vm.AllEmployees, "ViewModel should expose the same instance of the Employee collection so that changes outside the ViewModel are reflected.");
                Assert.AreSame(employees, vm.AllEmployees[0].ManagerLookup, "ViewModel should expose the same instance of the Employee collection to children so that changes outside the ViewModel are reflected.");
                Assert.AreSame(departments, vm.AllEmployees[0].DepartmentLookup, "ViewModel should expose the same instance of the Department collection to children so that changes outside the ViewModel are reflected.");
            }
        }