private ProductModel CreateModelFrom(Product product) { return new ProductModel { Name = product.Name, Category = product.Category, Discontinued = product.Discontinued }; }
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); }