/// <summary>
        /// Lauches the entry form on startup
        /// </summary>
        /// <param name="e">Arguments of the startup event</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            if (this.useFakes)
            {
                this.context = Generation.BuildFakeSession();
            }
            else
            {
                //NOTE: If there is not a Microsoft SQL Server Express instance available at .\SQLEXPRESS
                //      you will need to update the "EmployeeEntities" connection string in App.config
                this.context = new EmployeeEntities();
            }

            IDepartmentRepository departmentRepository = new DepartmentRepository(this.context);
            IEmployeeRepository   employeeRepository   = new EmployeeRepository(this.context);
            IUnitOfWork           unit = new UnitOfWork(this.context);

            MainViewModel main   = new MainViewModel(unit, departmentRepository, employeeRepository);
            MainView      window = new View.MainView {
                DataContext = main
            };

            window.Show();
        }
Exemple #2
0
        /// <summary>
        /// 启动时启动输入窗体
        /// </summary>
        /// <param name="e">startup 事件的参数</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            if (this.useFakes)
            {
                this.context = Generation.BuildFakeSession();
            }
            else
            {
                //注意: 如果 .\SQLEXPRESS 中没有 Microsoft SQL Server Express 实例,
                //      您将需要更新 App.config 中的“EmployeeEntities”连接字符串
                this.context = new EmployeeEntities();
            }

            IDepartmentRepository departmentRepository = new DepartmentRepository(this.context);
            IEmployeeRepository   employeeRepository   = new EmployeeRepository(this.context);
            IUnitOfWork           unit = new UnitOfWork(this.context);

            MainViewModel main   = new MainViewModel(unit, departmentRepository, employeeRepository);
            MainView      window = new View.MainView {
                DataContext = main
            };

            window.Show();
        }
Exemple #3
0
        public void Initialization()
        {
            using (FakeEmployeeContext ctx = Generation.BuildFakeSession())
            {
                UnitOfWork            unit = new UnitOfWork(ctx);
                IDepartmentRepository departmentRepository = new DepartmentRepository(ctx);
                IEmployeeRepository   employeeRepository   = new EmployeeRepository(ctx);
                IMapObjectRepository  mapRepository        = new MapRepository(ctx);

                int departmentCount = departmentRepository.GetAllDepartments().Count();
                int employeeCount   = employeeRepository.GetAllEmployees().Count();

                MainViewModel main = new MainViewModel(unit, departmentRepository, employeeRepository, mapRepository);

                Assert.IsNotNull(main.DepartmentWorkspace, "Department workspace should be initialized.");
                Assert.AreEqual(
                    departmentCount,
                    main.DepartmentWorkspace.AllDepartments.Count,
                    "Department workspace should contain all departments from repository.");

                Assert.IsNotNull(main.EmployeeWorkspace, "Employee workspace should be initialized.");
                Assert.AreEqual(
                    employeeCount,
                    main.EmployeeWorkspace.AllEmployees.Count,
                    "Employee workspace should contain all employees from repository.");

                Assert.IsNotNull(main.LongServingEmployees, "Long serving employee list should be initialized.");
                Assert.AreEqual(5, main.LongServingEmployees.Count(), "Long serving employee list should be restricted to five employees.");

                Assert.AreSame(
                    main.DepartmentWorkspace.AllDepartments,
                    main.EmployeeWorkspace.AllEmployees[0].DepartmentLookup,
                    "A single instance of the department list should be used so that adds/removes flow throughout the application.");

                Assert.AreSame(
                    main.EmployeeWorkspace.AllEmployees,
                    main.EmployeeWorkspace.AllEmployees[0].ManagerLookup,
                    "A single instance of the employee list should be used so that adds/removes flow throughout the application.");

                Assert.IsNotNull(main.SaveCommand, "SaveCommand should be initialized.");
            }
        }