예제 #1
0
        public void OrderShouldAddOrderDetail()
        {
            var order = new Order();
            var detail = new OrderDetail();

            order.AddOrderDetail(detail);
            Assert.AreSame(detail, order.OrderDetail);
        }
예제 #2
0
        public void OrderShouldSetItselfAsParentForOrderDetail()
        {
            var order = new Order();
            var detail = new OrderDetail();

            order.AddOrderDetail(detail);
            Assert.AreSame(order, detail.Order);
        }
예제 #3
0
        public void CustomerShouldRememberIdentityWhenInitializedFromDatabase()
        {
            var order = new Order();
            var guid = Guid.NewGuid();
            order.Id = guid;

            Assert.AreEqual(guid, order.Id);
        }
예제 #4
0
        public void CustomerShouldSetItselfAsAParentForItsOrders()
        {
            var customer = new Customer();
            var order = new Order();

            customer.AddOrder(order);
            Assert.AreSame(customer, order.Customer);
        }
예제 #5
0
        public void CustomerShouldAddOrderToOrders()
        {
            var customer = new Customer();
            var order = new Order();

            customer.AddOrder(order);
            CollectionAssert.Contains(customer.Orders, order);
        }
예제 #6
0
        public void OrderShouldAcceptRequiredDateAsStringAndSaveItAsADateTime()
        {
            var order = new Order();
            var date = new DateTime(2009, 9, 3);
            var stringDate = "03-09-2009";

            order.RequiredDateString = stringDate;
            Assert.AreEqual(date, order.RequiredDate);
        }
예제 #7
0
        private Customer GetCustomer()
        {
            var customer = new Customer
            {
                ContactName = "johnny",
                Email = "*****@*****.**",
                Country = "Italy"
            };

            var order1 = new Order
            {
                ShipName = "fjh rty",
                ShipAddress = "374 drgiaeroiu",
                ShipCity = "rtuket",
                ShipRegion = "reag qae",
                ShipPostalCode = "34573",
                ShipCountry = "tyjtwere"
            };

            var order2 = new Order
            {
                ShipName = "ghdgh",
                ShipAddress = "fjsr4 4545 fghsf",
                ShipCity = "fyjshrk",
                ShipRegion = "tdguyket",
                ShipPostalCode = "9345672",
                ShipCountry = "ryjsytr"
            };

            var detail = new OrderDetail
            {
                UnitPrice = 90.4m,
                Quantity = 28,
                Discount = 67.66m
            };

            order1.AddOrderDetail(detail);
            customer.AddOrder(order1);
            customer.AddOrder(order2);

            return customer;
        }
예제 #8
0
        private void Seed(ISession session)
        {
            var customers = new[] {new Customer()
                                          {
                                              ContactName = "Joe",
                                              City = "Kiev",
                                              Email = "*****@*****.**",
                                              Phone = "9236499234"
                                          },
                                          new Customer()
                                          {
                                              ContactName = "Cindy Crawford",
                                              City = "London",
                                              Email = "*****@*****.**",
                                              Phone = "928312934",
                                              Bool = true,
                                              CompanyName = "Company Ltd."
                                          },
                                          new Customer()
                                          {
                                              ContactName = "Petya",
                                              City = "New Delhi",
                                              Email = "*****@*****.**",
                                              Fax = "8982376495"
                                          },
                                          new Customer()
                                          {
                                              ContactName = "Vasiliy Zaycev",
                                              City = "Stalingrad",
                                              Email = "*****@*****.**",
                                              Bool = false
                                          },
                                          new Customer()
                                          {
                                              ContactName = "Another Joe",
                                              City = "Singapore",
                                              Email = "*****@*****.**",
                                              Phone = "42342234",
                                              ContactTitle = "Demon"
                                          }};
            var order1 = new Order()
                             {
                                 ShipName = "tratata",
                                 ShipAddress = "wwerwe rewr wer",
                                 ShipCity = "sdfsdf",
                                 ShipRegion = "erher",
                                 ShipPostalCode = "453453",
                                 ShipCountry = "sgaegar"
                             };
            order1.AddOrderDetail(new OrderDetail()
                                        {
                                            UnitPrice = 35.0m,
                                            Quantity = 345,
                                            Discount = 0.0m
                                        });
            customers[0].AddOrder(order1);
            order1 = new Order()
                         {
                             ShipName = "dfgjhr",
                             ShipAddress = "drhgerh reher her",
                             ShipCity = "erger",
                             ShipRegion = "rjrtje",
                             ShipPostalCode = "5645762",
                             ShipCountry = "ghsfjtser"
                         };
            order1.AddOrderDetail(new OrderDetail()
                                        {
                                            UnitPrice = 148.34m,
                                            Quantity = 21,
                                            Discount = 5.0m
                                        });
            customers[0].AddOrder(order1);
            customers[2].AddOrder(new Order()
                                        {
                                            ShipName = "fgjdfgjdfg",
                                            ShipAddress = "mdghdfy 4564 fgjhfgj",
                                            ShipCity = "yjtyj",
                                            ShipRegion = "jhrtjrtj",
                                            ShipPostalCode = "363634",
                                            ShipCountry = "tkethjdgfh"
                                        });
            order1 = new Order()
                         {
                             ShipName = "tratata",
                             ShipAddress = "456 fdhsdhaer aerh",
                             ShipCity = "dfhd",
                             ShipRegion = "wajsf",
                             ShipPostalCode = "56835",
                             ShipCountry = "dfhadethergh"
                         };
            order1.AddOrderDetail(new OrderDetail()
                                        {
                                            UnitPrice = 1649.0m,
                                            Quantity = 35,
                                            Discount = 9.7m
                                        });
            customers[3].AddOrder(order1);
            customers[3].AddOrder(new Order()
                                        {
                                            ShipName = "hhklfe",
                                            ShipAddress = "fdhdfh 45452 dfhadfher",
                                            ShipCity = "dfjlyuhet",
                                            ShipRegion = "sefsefr",
                                            ShipPostalCode = "873134",
                                            ShipCountry = "tydqaqe"
                                        });
            customers[3].AddOrder(new Order()
                                        {
                                            ShipName = "tratata",
                                            ShipAddress = "twerty eyer 65",
                                            ShipCity = "eryr tj",
                                            ShipRegion = "rtjsfrgjhas",
                                            ShipPostalCode = "0875986",
                                            ShipCountry = "tydgyjsf"
                                        });
            order1 = new Order()
                         {
                             ShipName = "frjsrt",
                             ShipAddress = "eagdfg eh aerhg 23",
                             ShipCity = "fghjsf",
                             ShipRegion = "frtjgtawe",
                             ShipPostalCode = "467967",
                             ShipCountry = "djsrtykswrt"
                         };
            order1.AddOrderDetail(new OrderDetail()
                                        {
                                            UnitPrice = 790.0m,
                                            Quantity = 15,
                                            Discount = 4.66m
                                        });

            using(var tx = session.BeginTransaction())
            {
                foreach (var c in customers)
                    session.Save(c);
                tx.Commit();
            }
        }
예제 #9
0
 public void OrderShouldAcceptRequiredDateAsNull()
 {
     var order = new Order();
     order.RequiredDate = null;
     Assert.IsNull(order.RequiredDateString);
 }
예제 #10
0
 public void CustomerShouldCreateIdentityWhenNotInitializedFromDatabase()
 {
     var order = new Order();
     Assert.AreNotEqual(Guid.Empty, order.Id);
 }
예제 #11
0
파일: Customer.cs 프로젝트: Mir4ik/TestRepo
 // Set up both sides of the relationship
 public virtual void AddOrder(Order order)
 {
     if (Orders == null)
         Orders = new List<Order>();
     order.Customer = this;
     Orders.Add(order);
 }