예제 #1
0
 public void Nh_HasRowVersion()
 {
     EmptyDatabase();
     IRepository<Product> db = new NH.Repository<Product>(NhModelsMapper.GetSession(connectionString));
     Common_HasRowVersion(db);
 }
예제 #2
0
파일: Tests.cs 프로젝트: MichaelBuen/DitTO
        public void Test_Dto_To_Live_Nh_Poco()
        {
            // Arrange
            OrderDto oDto = new OrderDto
            {
                OrderDate = new DateTime(2012, 07, 22),
                OrderDescription = "Hey Apple!",
                CustomerId = 1,
                CustomerName = "Hey",
                OrderLines = new[]
                {
                    new OrderLineDto { ProductoId = 1, Quantity = 7, Price = 6, Amount = 42 },
                    new OrderLineDto
                    {
                        ProductoId = 2, Quantity = 3, Price = 6, Amount = 18, FreebieId = 1,
                        Koments = new[]
                        {
                            new CommentDto { TheComment = "Great" },
                            new CommentDto { TheComment = "Nice" }
                        }
                    },
                    new OrderLineDto { ProductoId = 1, Quantity = 4, Price = 5, Amount = 20, FreebieId = 2 },
                }
            };

            // Act
            Order oPoco = Mapper.ToPoco<OrderDto,Order>(oDto);

            // Assert
            using (ISession s = NhDbMapper.GetSession(connectionString))
            {
                var db = new NH.Repository<Order>(s);
                db.Save(oPoco);

                Assert.AreNotEqual(0, oPoco.OrderId);
                Assert.AreEqual(3, db.Get(oPoco.OrderId).OrderLines.Count);
            }
        }
예제 #3
0
 public void Nh_Can_Save_Then_Update()
 {
     EmptyDatabase();
     IRepository<Product> dbProd = new NH.Repository<Product>(NhModelsMapper.GetSession(connectionString));
     IRepository<ProductPrice> dbPrice = new NH.Repository<ProductPrice>(NhModelsMapper.GetSession(connectionString));
     Common_Can_Save_Then_Update(dbProd, dbPrice);
 }
예제 #4
0
        public void Nh_Can_save_transaction()
        {
            EmptyDatabase();

            NHibernate.ISession x = NhModelsMapper.GetSession(connectionString);
            ITransactionBoundFactory xf = new NH.TransactionBoundFactory(x);

            IRepository<Product> prod = new NH.Repository<Product>(x);
            IRepository<Question> ques = new NH.Repository<Question>(x);
            Common_Can_save_transaction(xf, prod, ques);
        }
예제 #5
0
 public void Nh_Can_Orm_SaveGraph_Can_Update()
 {
     EmptyDatabase();
     IRepository<Question> db = new NH.Repository<Question>(NhModelsMapper.GetSession(connectionString));
     Common_Orm_SaveGraph_Can_Update(db);
 }
예제 #6
0
 public void Nh_Can_queue_changes()
 {
     EmptyDatabase();
     IRepository<Question> db = new NH.Repository<Question>(NhModelsMapper.GetSession(connectionString));
     Common_Can_queue_changes(db);
 }
예제 #7
0
 public void Nh_Can_Orm_do_cascaded_deletions()
 {
     EmptyDatabase();
     IRepository<Question> db = new NH.Repository<Question>(NhModelsMapper.GetSession(connectionString));
     Common_Can_Orm_do_cascaded_deletions(db);
 }
예제 #8
0
        public void Nh_Can_Fetch_Eager_Load()
        {
            EmptyDatabase();
            IRepository<Question> db = new NH.Repository<Question>(NhModelsMapper.GetSession(connectionString));
            Test_Can_Fetch_Eager_Load_Common(db);

            // Arrange
            EmptyDatabase();
            Question qx = new Question { Text = "42" };
            db.Save(qx);
            db.Evict(qx.QuestionId);

            // Act
            var qq = NH.EagerExtensionHelper.EagerLoad(db.All.Where(x => x.QuestionId == qx.QuestionId), "Answers").SingleOrDefault();

            // Assert
            Assert.AreEqual("42", qq.Text);
        }
예제 #9
0
 public void Nh_CanSaveHeaderDetail_ThenHeaderOnly()
 {
     EmptyDatabase();
     IRepository<Product> db = new NH.Repository<Product>(NhModelsMapper.GetSession(connectionString));
     // throw new Exception("Provider : " + db.All.Provider.GetType().ToString()); // NHibernate.Linq.NhQueryProvider
     Common_CanSaveHeaderDetail_ThenHeaderOnly(db);
 }
예제 #10
0
 public void Nh_CanHaveIncrementingKey()
 {
     EmptyDatabase();
     IRepository<Product> db = new NH.Repository<Product>(NhModelsMapper.GetSession(connectionString));
     Common_CanHaveIncrementingKey(db);
 }
예제 #11
0
 public void Nh_CanDetectUpdateConflictingUpdate()
 {
     EmptyDatabase();
     IRepository<Product> db = new NH.Repository<Product>(NhModelsMapper.GetSession(connectionString));
     Common_CanDetectUpdateConflictingUpdate(db);
 }