Esempio n. 1
0
 public void SetUp()
 {
     var mapper = new DtoMapper(new LinkProvider());
      m_order = new Order();
      m_order.Pay("123", "jose");
      m_dto = mapper.Map<Order, OrderDto>(m_order);
 }
Esempio n. 2
0
        public void CanStoreAnOrderWithPayment()
        {
            long id;
            using (var session = m_sessionFactory.OpenSession())
            using (var tx = session.BeginTransaction())
            {
                var productRepository = new Repository<Product>(session);
                var product = new Product { Name = "Latte", Price = 10.4m };
                productRepository.MakePersistent(product);

                var orderRepository = new Repository<Order>(session);
                var order = new Order
                {
                    Date = new DateTime(2011, 1, 1),
                    Location = Location.InShop,
                };
                order.AddItem(new OrderItem
                                    {
                                       Product = product,
                                       UnitPrice = 10.4m,
                                       Preferences =
                                           {
                                               {"Milk", "skim"},
                                               {"Size", "small"}
                                           }
                                    });
                orderRepository.MakePersistent(order);
                order.Pay("1234", "jose");
                id = order.Id;
                tx.Commit();
            }

            using (var context = m_sessionFactory.OpenSession())
            {
                var repository = new Repository<Order>(context);
                var order = repository.GetById(id);
                order.Satisfy(a_o => a_o.Location == Location.InShop
                                && a_o.Items.Count() == 1
                                && a_o.Payment != null);
            }
        }
Esempio n. 3
0
        public void VersionNumberGrowOnEachUpdate()
        {
            long id;
            int version;
            using (var session = m_sessionFactory.OpenSession())
            using (var tx = session.BeginTransaction())
            {
                var productRepository = new Repository<Product>(session);
                var product = new Product {Name = "Latte", Price = 10.4m};
                productRepository.MakePersistent(product);

                var orderRepository = new Repository<Order>(session);
                var order = new Order
                                {
                                    Date = new DateTime(2011, 1, 1),
                                    Location = Location.InShop,
                                };
                order.AddItem(new OrderItem
                                  {
                                      Product = product,
                                      UnitPrice = 10.4m,
                                      Preferences =
                                          {
                                              {"Milk", "skim"},
                                              {"Size", "small"}
                                          }
                                  });
                orderRepository.MakePersistent(order);
                order.Pay("1234", "jose");
                id = order.Id;

                tx.Commit();
                version = order.Version;
            }
            using (var session = m_sessionFactory.OpenSession())
            using (var tx = session.BeginTransaction())
            {
                var order = session.Get<Order>(id);
                order.Location = Location.TakeAway;
                tx.Commit();

                order.Version.Should().Be.GreaterThan(version);
            }
        }