public void EmployeeDeleteTest()
        {
            using (IDataContext context = new AdminSoftContext())
            {
                IEmployeeRepository service = new EmployeeRepository(context);
                int id = 0;
                //insert employee to delete
                Employee employee = new Employee()
                {
                    FirstName = "Petter",
                    LastName  = "Leverling",
                    Address   = "908 W. Capital Way",
                    City      = "London",
                    Phone     = "(71) 555-4848"
                };
                service.Insert(employee);
                id = employee.EmployeeId.Value;
                Assert.IsNotNull(employee);

                //delete employee
                employee = service.Find(id);
                service.Delete(employee);
                Assert.IsNotNull(employee.EmployeeId);
            }
        }
 public void EmployeeGetAllTest()
 {
     using (IDataContext context = new AdminSoftContext())
     {
         IEmployeeRepository service = new EmployeeRepository(context);
         var employees = service.GetAll();
         Assert.IsNotNull(employees);
     }
 }
 public void EmployeeFindByIdTest()
 {
     using (IDataContext context = new AdminSoftContext())
     {
         IEmployeeRepository service = new EmployeeRepository(context);
         var employee = service.Find(1);
         Assert.IsNotNull(employee);
     }
 }
 public BaseRepository(DbContext context)
 {
     if (context == null)
     {
         throw new Exception("El contexto no puede se nulo: BaseRepository");
     }
     if (context is AdminSoftContext)
     {
         _context = context as AdminSoftContext;
     }
     else
     {
         throw new Exception("El contexto no es valido: BaseRepository");
     }
     _entities = _context.Set <TEntity>();
 }
 public void EmployeeInsertTest()
 {
     using (IDataContext context = new AdminSoftContext())
     {
         IEmployeeRepository service  = new EmployeeRepository(context);
         Employee            employee = new Employee()
         {
             FirstName = "Petter",
             LastName  = "King",
             Address   = "908 W. Capital Way",
             City      = "London",
             Phone     = "(71) 555-4848"
         };
         service.Insert(employee);
         Assert.IsNotNull(employee.EmployeeId);
     }
 }
        public void EmployeeQueryTest()
        {
            using (IDataContext context = new AdminSoftContext())
            {
                IEmployeeRepository service = new EmployeeRepository(context);

                //Filters
                var employee = new Employee()
                {
                    City = "London"
                };

                //exec query
                var employees = service.Query(employee, "City DESC");
                Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(employee);
            }
        }
        public void EmployeeQueryPageTest()
        {
            using (IDataContext context = new AdminSoftContext())
            {
                IEmployeeRepository service = new EmployeeRepository(context);
                int totalRows = 0;

                //Filters
                var employee = new Employee()
                {
                    City = "London"
                };

                //Consultar paginado
                var employees = service.QueryPage(null, out totalRows, 0, 10, "City ASC");
                Assert.IsNotNull(employees);
            }
        }
        public void EmployeeUpdateTest()
        {
            using (IDataContext context = new AdminSoftContext())
            {
                IEmployeeRepository service = new EmployeeRepository(context);

                //Get employee to update
                Employee employee = new Employee()
                {
                    FirstName = "Janet"
                };
                employee = service.Query(employee).FirstOrDefault();
                Assert.IsNotNull(employee);

                //update employee
                employee.Phone = "(71) 555-4848";
                service.Update(employee);
                Assert.IsNotNull(employee.EmployeeId);
            }
        }