コード例 #1
0
ファイル: EmployeeTest.cs プロジェクト: ronymaychan/adminsoft
        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);
            }
        }
コード例 #2
0
ファイル: EmployeeTest.cs プロジェクト: ronymaychan/adminsoft
 public void EmployeeGetAllTest()
 {
     using (IDataContext context = new AdminSoftContext())
     {
         IEmployeeRepository service = new EmployeeRepository(context);
         var employees = service.GetAll();
         Assert.IsNotNull(employees);
     }
 }
コード例 #3
0
ファイル: EmployeeTest.cs プロジェクト: ronymaychan/adminsoft
 public void EmployeeFindByIdTest()
 {
     using (IDataContext context = new AdminSoftContext())
     {
         IEmployeeRepository service = new EmployeeRepository(context);
         var employee = service.Find(1);
         Assert.IsNotNull(employee);
     }
 }
コード例 #4
0
 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>();
 }
コード例 #5
0
ファイル: EmployeeTest.cs プロジェクト: ronymaychan/adminsoft
 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);
     }
 }
コード例 #6
0
ファイル: EmployeeTest.cs プロジェクト: ronymaychan/adminsoft
        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);
            }
        }
コード例 #7
0
ファイル: EmployeeTest.cs プロジェクト: ronymaychan/adminsoft
        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);
            }
        }
コード例 #8
0
ファイル: EmployeeTest.cs プロジェクト: ronymaychan/adminsoft
        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);
            }
        }