Example #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);
                    }
        }
Example #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);
                    }
        }
Example #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);
                    }
        }
Example #4
0
 public Repository(EmployeeManagementContext ctx)
 {
     _ctx       = ctx;
     this.dbSet = _ctx.Set <T>();
 }
Example #5
0
 public IList <T> GetAll <T>() where T : EntityBase
 {
     return(context.Set <T>().ToList());
 }