protected override void OnSetUp() { using (var session = OpenSession()) using (var transaction = session.BeginTransaction()) { var product = new Product("T001", "T-Shirt"); var product2 = new Product("U001", "Underwear"); var variant = new ProductVariant("RED", "R001", product); var variant2 = new ProductVariant("YELLOW", "Y001", product2); product.AddVariant(variant); product2.AddVariant(variant2); session.Save(product); session.Save(product2); var user = new MembershipUser(25, "*****@*****.**", "OguzhanSoykan"); var emailHistory = new MembershipUserEmailHistory(DateTime.Now, "*****@*****.**", user); var address = new MembershipUserAddress("221b baker street", user); var phone = new MembershipUserPhone("55544433322", user); var segment = new MembershipUserSegment("Rich User", DateTime.Now, user); user.AddAddress(address).AddEmailHistory(emailHistory).AddPhone(phone).AddSegment(segment); session.Save(user); var basket = new MembershipUserBasket(Guid.NewGuid(), DateTime.Now, user); basket.AddProduct(new MembershipUserBasketProduct(basket, DateTime.Now, product)); basket.AddProduct(new MembershipUserBasketProduct(basket, DateTime.Now, product2)); var orderline = new MembershipOrderLine(product, 8); var orderline2 = new MembershipOrderLine(product2, 2); var order = new MembershipOrder(user, basket).AddOrderLine(orderline).AddOrderLine(orderline2); session.Save(order); session.Flush(); transaction.Commit(); } }
public virtual MembershipUserBasket SetOrder(MembershipOrder order) { this.Order = order; return this; }