Esempio n. 1
0
        public void MuiltChangeTest()
        {
            var unitOfWorkObj = new EfUnitOfWork(null /*ILogger*/); //{ DbContextFactory = _dbContextFactory };

            var uoWdbContextProvider = new EfUnitOfWorkDbContextProvider(new EfUnitOfWorkManager(IoCManager, null /*ILogger*/), IoCManager, null /*ILogger*/);
            var orderRepo            = new FakeOrderRepository(uoWdbContextProvider);
            var productRepo          = new FakeProductRepository(uoWdbContextProvider);
            var userRepo             = new FakeUserRepository(uoWdbContextProvider);

            unitOfWorkObj.Begin(new UnitOfWorkOption());
            try
            {
                //orderRepo.Insert(FakeOrder.Fake());
                productRepo.InsertAsync(FakeProduct.Fake()).GetAwaiter();
                userRepo.InsertAsync(FakeUser.Fake()).GetAwaiter();
                unitOfWorkObj.CommitAsync().GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                //Assert.F("发生异常:" + ex.Message);
            }
            finally
            {
                unitOfWorkObj.Dispose();
            }
        }