Exemple #1
0
 public void CanPersistOrder()
 {
     IRepository repo = new HibernateRepo();
     try
     {
         repo.BeginTransaction();
         Customer customer = repo.First<Customer>(c => c.CustomerId == 1);
         ISalesTaxCalculator salesCalculator = new SalesTaxCalculator();
         Order order = new Order(customer, salesCalculator);
         order.With(new OrderLine(this.GetProduct(repo,3), 1))
              .With(new OrderLine(this.GetProduct(repo, 4), 12));
         repo.Add<Order>(order);
         repo.SaveChanges();
         repo.CommitTransaction();
     }
     catch (Exception ex)
     {
         repo.Rollback();
         throw ex;
     }
     finally
     {
         repo.Dispose();
     }
 }
Exemple #2
0
 public void CreateOrder()
 {
     ISalesTaxCalculator salesCalculator = new SalesTaxCalculator();
     Order order = new Order(new Customer("sony", "blr"), salesCalculator);
     Assert.AreNotEqual(order, null, "Order created successfully");
     order.With(new OrderLine(_productCatalogs[0],1))
         .With(new OrderLine(_productCatalogs[1],1));
     Assert.AreEqual(28.98, order.GetGrandTotal().Value);
     Assert.AreEqual(1.5, order.GetTotalTax().Value );
 }
Exemple #3
0
 internal void SetOrder(Order order)
 {
     _order = order;
 }