private void CreateInitialData()
		{
			using (var unitOfWork = new UnitOfWork(_sessionFactory))
			{
				foreach (var product in _products)
				{
					unitOfWork.CurrentSession.Save(product);
				}
				unitOfWork.Commit();
			}
		}
        public void Should_be_able_to_update_an_existing_product()
        {
            var product = _products[0];
            product.Name = "Yellow Pear";
            using (var unitOfWork = new UnitOfWork(_sessionFactory))
            {
                unitOfWork.CurrentSession.Update(product);
                unitOfWork.Commit();
            }

            // use session to try to load the product
            using (var unitOfWork = new UnitOfWork(_sessionFactory))
            {
                var fromDb = unitOfWork.CurrentSession.Get<Product>(product.Id);
                Assert.AreEqual(product.Name, fromDb.Name);
            }
        }
        public void Should_be_able_to_add_new_products()
        {
            var product = new Product {Name = "Apple", Category = "Fruits"};
            using (var unitOfWork = new UnitOfWork(_sessionFactory))
            {
                unitOfWork.CurrentSession.Save(product);
                unitOfWork.Commit();
            }

            Product fromDb;
        
            using (var session = _sessionFactory.OpenSession())
            {
                fromDb = session.Get<Product>(product.Id);                
            }

            // Test that the product was successfully inserted
            Assert.IsNotNull(fromDb);
            Assert.AreNotSame(product,fromDb);
            Assert.AreEqual(product.Name, fromDb.Name);
            Assert.AreEqual(product.Category, fromDb.Category);            
        }
        public void Should_be_able_to_remove_an_existing_product()
        {
            var product = _products[0];
            using (var unitOfWork = new UnitOfWork(_sessionFactory))
            {
                unitOfWork.CurrentSession.Delete(product);
                unitOfWork.Commit();
            }

            using (var unitOfWork = new UnitOfWork(_sessionFactory))
            {
                var fromDb = unitOfWork.CurrentSession.Get<Product>(product.Id);
                Assert.IsNull(fromDb);
            }
        }