public void Nh_HasRowVersion()
 {
     EmptyDatabase();
     IRepository<Product> db = new NH.Repository<Product>(NhModelsMapper.GetSession(connectionString));
     Common_HasRowVersion(db);
 }
Beispiel #2
0
        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);
            }
        }
 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);
 }
        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);
        }
 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);
 }
 public void Nh_Can_queue_changes()
 {
     EmptyDatabase();
     IRepository<Question> db = new NH.Repository<Question>(NhModelsMapper.GetSession(connectionString));
     Common_Can_queue_changes(db);
 }
 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);
 }
        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);
        }
 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);
 }
 public void Nh_CanHaveIncrementingKey()
 {
     EmptyDatabase();
     IRepository<Product> db = new NH.Repository<Product>(NhModelsMapper.GetSession(connectionString));
     Common_CanHaveIncrementingKey(db);
 }
 public void Nh_CanDetectUpdateConflictingUpdate()
 {
     EmptyDatabase();
     IRepository<Product> db = new NH.Repository<Product>(NhModelsMapper.GetSession(connectionString));
     Common_CanDetectUpdateConflictingUpdate(db);
 }