示例#1
0
        public void TestMethod1()
        {
            var dbContext = new DanwuDbContext();
            var context = new EntityFrameworkRepositoryContext();
            var unitOfWork = new EntityFrameworkUnitOfWork(dbContext);
            IUserRepository userRepository = new UserRepository(context);
            userRepository.Create(new User()
            {
                UserName = "******",
                NickName = "坏坏男孩",
                RealName = "吴丹",
                PhoneNum = "18916765826",
                Email = "*****@*****.**",
                Status = UserStatus.Enabled,
                PassWord = "******",
                RegisterTime = DateTime.Now,
                LastLogonTime = DateTime.Now
            });
            userRepository.Create(new User()
            {
                UserName = "******",
                NickName = "坏坏男孩1",
                RealName = "吴丹1",
                PhoneNum = "18916765000",
                Email = "*****@*****.**",
                Status = UserStatus.Disabled,
                PassWord = "******",
                RegisterTime = DateTime.Now,
                LastLogonTime = DateTime.Now
            });

            var result = context.Commit();
            //var result = unitOfWork.Commit();
        }
 public void GetBookseller()
 {
     IRepositoryContext uow = new EntityFrameworkRepositoryContext();
     var repo = new BooksellerRepository(uow);
     var result = repo.GetAll();
     Assert.IsTrue(result.Count() > 0);
 }
示例#3
0
        public void TestMethod2() {
            var dbContext = new DanwuDbContext();
            var context = new EntityFrameworkRepositoryContext();
            var unitOfWork = new EntityFrameworkUnitOfWork(dbContext);
            IUserRepository userRepository = new UserRepository(context);
            var users = userRepository.QueryAll();

            //users=userRepository.QueryBy(
        }
 public void AddBookseller()
 {
     IRepositoryContext uow = new EntityFrameworkRepositoryContext();
     var repo = new BooksellerRepository(uow);
     var bookseller = new Bookseller { Contact = "张三", Name = "测试", Telephone = "123456" };
     repo.Add(bookseller);
     repo.Context.Commit();
     var result = repo.Single(t =>
         t.Contact == bookseller.Contact &&
         t.Name == bookseller.Name &&
         t.Telephone == bookseller.Telephone
         );
     Assert.IsNotNull(result.ID);
 }
        public void Initialize()
        {
            var context = new EntityFrameworkRepositoryContext(new BlogContext());
            WebLogs = new GenericRepository<WebLog>(context);

            var title = Guid.NewGuid().ToString();

            var user = new User { Name = "user " + title };
            var webLog = new WebLog { Title = webLogID, CreatedAt = DateTime.Now };
            var post = new Post { Title = postID, Text = "oi", CreatedAt = DateTime.Now, LastUpdatedAt = DateTime.Now, PublishedAt = DateTime.Now };

            webLog.Collaborators.Add(user);
            user.AddBlog(webLog);
            webLog.Posts.Add(post);
            post.WebLog = webLog;

            WebLogs.SaveOrUpdate(webLog);
        }
示例#6
0
        static void CachePerformanceTest(Boolean cachingEnabled)
        {
            DateTime started = DateTime.Now;
            Int32 loopymax = 100000;
            EntityFrameworkRepositoryContext<TheoreticalEntities> context
                = new EntityFrameworkRepositoryContext<TheoreticalEntities>();
            OrderDataMapBlock blocky;

            for (Int32 i = 0; i < loopymax; i++)
            {
                blocky = new OrderDataMapBlock();
                //blocky.Context = context;
                blocky.CachingEnabled = cachingEnabled;

                blocky.TouchDataMap();
            }
            var stringy = cachingEnabled ? "(Caching)" : "(No caching)";
            Console.WriteLine("Time to complete" + stringy + ": " + DateTime.Now.Subtract(started).TotalSeconds.ToString());
        }
 public void GetDepartment()
 {
     IRepositoryContext uow = new EntityFrameworkRepositoryContext();
     var repo = new DepartmentRepository(uow);
     var result = repo.GetAll();
     Assert.IsTrue(result.Count() > 0);
 }
 public void GetTbmisUserWithRole()
 {
     IRepositoryContext uow = new EntityFrameworkRepositoryContext();
     var repo = new TbmisUserRepository(uow);
     var user = repo.First(t => t.UserName == "46010");
     Assert.IsTrue(user.IsInRole("教师"));
 }
 public void GetStudentReleaseRecord()
 {
     IRepositoryContext uow = new EntityFrameworkRepositoryContext();
     var repo = new StudentReleaseRecordRepository(uow);
     var result = repo.GetAll();
     Assert.IsTrue(result.Count() > 0);
 }
 public void GetStudentDeclarationJiaoWuByRepo()
 {
     //IUnitOfWork uow = new TbMisUnitOfWork();
     IRepositoryContext uow = new EntityFrameworkRepositoryContext();
     var repo = new StudentDeclarationJiaoWuRepository(uow);
     var result = repo.GetAll();
     //Find(t => t.SchoolYearTerm.Year == "2011-2012" && t.SchoolYearTerm.Term == "2");
     //.Where(t => t.CanSubscribe);
     Assert.IsTrue(result.Count() > 0);
 }
 public void GetStorage()
 {
     IRepositoryContext uow = new EntityFrameworkRepositoryContext();
     var repo = new StorageRepository(uow);
     var result = repo.GetAll();
     Assert.IsTrue(result.Count() == 0);
 }
 public void GetProfessionalClass()
 {
     IRepositoryContext uow = new EntityFrameworkRepositoryContext();
     var repo = new ProfessionalClassRepository(uow);
     var result = repo.GetAll();
     Assert.IsTrue(result.Count() > 0);
 }
示例#13
0
        static void PerformanceUpdateMapperTest(Int32 numberOfInserts, Boolean proxiesEnabled, Boolean lazyEnabled)
        {
            DateTime started = DateTime.Now;
            Int32 loopymax = numberOfInserts;
            EntityFrameworkRepositoryContext<TheoreticalEntities> context = new EntityFrameworkRepositoryContext<TheoreticalEntities>();
            OrderPocoDataMapBlock blocky = new OrderPocoDataMapBlock();
            blocky.Context = context;

            context.DbContext.Configuration.ProxyCreationEnabled = proxiesEnabled;
            context.DbContext.Configuration.LazyLoadingEnabled = lazyEnabled;

            var updateTarget = blocky.FindFirst();

            for (Int32 i = 0; i < loopymax; i++)
            {
                updateTarget.OptionalNote = "Giggidy" + i.ToString();

                if (i % 2 == 0)
                {
                    updateTarget.OrderInformation.Add(new OrderInformationPoco()
                    {
                        TrackAmount = Convert.ToDecimal(i) * 100,
                        TrackDate = DateTime.Now,
                        TrackingNumber = "tracky" + i.ToString()
                    });
                }
                else
                {
                    var minDate = updateTarget.OrderInformation
                         .Where(a => a.OrderInformationId > 0).Min(a => a.OrderInformationId);

                    updateTarget.OrderInformation.Remove(updateTarget.OrderInformation
                        .Where(a => a.OrderInformationId == minDate).First());
                }

                blocky.Update(updateTarget);

                context.SaveChanges();
            }

            Console.WriteLine("Performance update datamapper time to complete:" + DateTime.Now.Subtract(started).TotalSeconds.ToString());
        }
示例#14
0
        static void PerformanceAddMapperTest(Int32 numberOfInserts, Boolean proxiesEnabled, Boolean lazyEnabled)
        {
            DateTime started = DateTime.Now;
            Int32 loopymax = numberOfInserts;
            EntityFrameworkRepositoryContext<TheoreticalEntities> context = new EntityFrameworkRepositoryContext<TheoreticalEntities>();
            OrderPocoDataMapBlock blocky = new OrderPocoDataMapBlock();
            blocky.Context = context;

            context.DbContext.Configuration.ProxyCreationEnabled = proxiesEnabled;
            context.DbContext.Configuration.LazyLoadingEnabled = lazyEnabled;

            for (Int32 i = 0; i < loopymax; i++)
            {
                var newPoco = CreateNewOrderPoco();

                blocky.Add(newPoco);

                context.SaveChanges();
            }

            Console.WriteLine("Performance add datamapper time to complete:" + DateTime.Now.Subtract(started).TotalSeconds.ToString());
        }
示例#15
0
        static void DataMapBlockOdd()
        {
            try
            {
                OrderPocoDataMapBlock dataMapBlock = new OrderPocoDataMapBlock();
                EntityFrameworkRepositoryContext<TheoreticalEntities> context = new EntityFrameworkRepositoryContext<TheoreticalEntities>();
                dataMapBlock.Context = context;

                var findResult = dataMapBlock.TryFind(134);

                var addOrder = CreateNewOrderPoco();

                addOrder.Status = StatusEnum.Giggidy;

                //sl.Add(addOrder);
                dataMapBlock.Add(addOrder);
                context.SaveChanges();

                var addFindResult = dataMapBlock.TryFind(addOrder.MyId);

                //remove last and add a new one.
                addFindResult.MyOrderPocoItems.Remove(addFindResult.MyOrderPocoItems.Last());
                addFindResult.MyOrderPocoItems.Add(new OrderItemPoco()
                {
                    HasSerialNumber = false,
                    SalePrice = 1000M,
                    SerialNumber = "ADDEDITEM",
                    RenamedUpc = "ADDUPC",
                    ConcurrencyId = 0
                });

                dataMapBlock.Update(addFindResult);
                context.SaveChanges();

                addFindResult.OrderInformation.Last().TrackingNumber = "Giggidy";

                dataMapBlock.Update(addFindResult);
                context.SaveChanges();

                dataMapBlock.Delete(addFindResult);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
        }