예제 #1
0
        public void Should_Be_Able_To_Retrieve_Employee_From_DB()
        {
            using (var context = new EmployeeManagementContext())
                using (var repo = new EmployeeRepository(context))
                    using (var txn = context.Database.BeginTransaction())
                    {
                        context.Set <EmployeeEntity>().AddRange(Data.EmployeeEntities);
                        context.SaveChanges();

                        var employee = repo.GetEmployee(Data.User1Id);

                        txn.Rollback();

                        Assert.IsNotNull(employee);
                    }
        }
예제 #2
0
        public void Should_Be_Able_To_Retrieve_All_Employees_From_DB()
        {
            using (var context = new EmployeeManagementContext())
                using (var repo = new EmployeeRepository(context))
                    using (var txn = context.Database.BeginTransaction())
                    {
                        context.Set <EmployeeEntity>().AddRange(Data.EmployeeEntities);
                        context.SaveChanges();

                        var employees = repo.GetAllEmployees();

                        txn.Rollback();

                        Assert.AreEqual(2, employees.Count);
                    }
        }
예제 #3
0
        public void Should_Be_Able_To_Get_Add_Employee_To_DB()
        {
            using (var context = new EmployeeManagementContext())
                using (var repo = new EmployeeRepository(context))
                    using (var txn = context.Database.BeginTransaction())
                    {
                        var employee = Data.EmployeeEntities[0];

                        repo.Create(employee);

                        var dbEmployee = context.Set <EmployeeEntity>().Find(Data.User1Id);

                        txn.Rollback();

                        Assert.IsNotNull(dbEmployee);
                    }
        }
예제 #4
0
 public Repository(EmployeeManagementContext ctx)
 {
     _ctx       = ctx;
     this.dbSet = _ctx.Set <T>();
 }
예제 #5
0
 public IList <T> GetAll <T>() where T : EntityBase
 {
     return(context.Set <T>().ToList());
 }