Esempio n. 1
0
        public void SaveWithProduct()
        {
            // ts.Dispose();
            var c = new Category { Name = "olo" };

            var p = new Product { Title = "olo" };

            c.Products.Add(p);
            var p2 = new Product { Title = "olo2" };
            Category fromDb;
            c.Products.Add(p2);
            //p.CategoryId = c.Id;
            using (var session = factory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    session.Save(c);
                    transaction.Commit();
                }
            }
            using (var session = factory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    fromDb = session.Get<Category>(c.Id);
                }
                Assert.That(fromDb.Products.Count == 2);
            }
        }
Esempio n. 2
0
        private async Task <Product> GetProductAsync()
        {
            var product = new Product()
            {
                Price = 200
            };

            return(await Task.FromResult(product));
        }
Esempio n. 3
0
        public void SaveWithPicture()
        {
            Product p;

            using (var session = factory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    p = new Product { Title = "Tytu³", Price = 90m, Description = "jakisopis" };
                    session.Save(p);
                    var pic = new Picture();
                    p.AddPicture(pic);

                    transaction.Commit();
                }
            }
            using (var session = factory.OpenSession())
            {
                var fromDb=session.Get<Product>(p.Id);

                Assert.That(fromDb.Pictures.Count(),Is.EqualTo(1));
            }
        }
Esempio n. 4
0
 public void Save()
 {
     var c = new Category {Name = "olo"};
     var p = new Product {Category = c};
     using (var session = factory.OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             session.Save(c);
             session.Save(p);
             transaction.Commit();
         }
     }
     Product fromDb;
     using (var session = factory.OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             fromDb = session.Get<Product>(p.Id);
             Assert.That(fromDb.Category.Id == c.Id);
         }
     }
 }
Esempio n. 5
0
 public void Basic()
 {
     var p = new Product();
     Assert.IsNotNull(p, "nie utworzy³");
 }