Ejemplo n.º 1
0
        public void UnitOfWork_Service_Pattern_Test()
        {
            var context = new NORTHWNDEntities();

            using (IUnitOfWork unitOfWork = new UnitOfWork(context))
            {
                unitOfWork.BeginTransaction();
                var customerService = new CustomerService(unitOfWork);
                customerService.Insert(new Customers
                {
                    CustomerID  = "YAMI1",
                    CompanyName = "Deneme - CompanyName"
                });

                unitOfWork.SaveChanges();
                unitOfWork.RollbackTransaction();

                unitOfWork.Dispose();
                var isDisposed = (bool)GetInstanceField(typeof(UnitOfWork), unitOfWork, "_disposed");
                Assert.IsTrue(isDisposed);

                unitOfWork.Dispose();
                context.Dispose();

                context.Dispose();
                unitOfWork.Dispose();
            }
        }
Ejemplo n.º 2
0
        public void Service_Pattern_GetData()
        {
            var context = new NORTHWNDEntities();

            using (IUnitOfWork unitOfWork = new UnitOfWork(context))
            {
                var customerService = new CustomerService(unitOfWork);
                var result          = customerService.GetFirstOrDefault();
                Assert.IsNotNull(result.ResultObject.CompanyName);
            }
        }
Ejemplo n.º 3
0
        public void Repository_Pattern_GetData_Test()
        {
            var context = new NORTHWNDEntities();

            using (IUnitOfWork unitOfWork = new UnitOfWork(context))
            {
                IRepository <Customers> customerRepository = unitOfWork.Repository <Customers>();
                var retVal = customerRepository.GetFirstOrDefault();
                Assert.IsNotNull(retVal.Address);
            }
        }
Ejemplo n.º 4
0
        public void Service_Pattern_GetData_CustomersByCompany()
        {
            var context = new NORTHWNDEntities();

            using (IUnitOfWork unitOfWork = new UnitOfWork(context))
            {
                var customerService = new CustomerService(unitOfWork);
                var result          = customerService.CustomersByCompany("bon");
                Assert.IsNotNull(result);
            }
        }