Esempio n. 1
0
            public static void Initialize()
            {
                IAccountRepository accRepo = new Moq.Mock<IAccountRepository>().Object;
                ISessionRepository sessionRepo = new Moq.Mock<ISessionRepository>().Object;
                IPOSSettingRepository posSettingRepo = new Moq.Mock<IPOSSettingRepository>().Object;
                Moq.Mock<IProductRepository> productRepo = new Moq.Mock<IProductRepository>();
                product_1 = new Product(Guid.NewGuid(), "Product ABC", "001", "001", 2000);
                productRepo.Setup(i => i.GetByBarcodeOrCode("001")).Returns(product_1);

                Moq.Mock<ICompanyProfileRepository> cpRepo = new Moq.Mock<ICompanyProfileRepository>();
                cpRepo.Setup(i => i.Get()).Returns(new CompanyProfile("*****@*****.**", "123", "Toko Dny", "Diamond Palace", null));

                AutoNumber autoNumber = new AutoNumber("*****@*****.**", "123", DateTime.Now);
                Moq.Mock<IAutoNumberRepository> autoNumberRepo = new Moq.Mock<IAutoNumberRepository>();
                autoNumberRepo.Setup(i => i.Get(DateTime.Now)).Returns(autoNumber);

                var sessionHolder = new SessionHolder();
                ObjectFactory.Initialize(i =>
                {
                    i.For<IAccountRepository>().Use(accRepo);
                    i.For<ISessionRepository>().Use(sessionRepo);
                    i.For<ICompanyProfileRepository>().Use(cpRepo.Object);
                    i.For<SessionService>().Use<SessionService>();
                    i.For<ShoppingCartService>().Use<ShoppingCartService>();
                    i.ForSingletonOf<SessionHolder>().Use<SessionHolder>();
                    i.For<IProductRepository>().Use(productRepo.Object);
                    i.For<IPOSSettingRepository>().Use(posSettingRepo);
                    i.ForSingletonOf<SessionHolder>().Use(sessionHolder);
                    i.ForSingletonOf<IShoppingCartSingleton>().Use(sessionHolder);
                    i.For<IAutoNumberRepository>().Use(autoNumberRepo.Object);
                    i.For<AutoNumberGenerator>().Use<AutoNumberGenerator>();
                });
            }
Esempio n. 2
0
 internal Item(Product product, int quantity, DiscountRate discountRate)
     : this()
 {
     this.Product = product;
     this.Quantity = 1;
     this.DiscountRate = discountRate;
     Calculate();
 }
Esempio n. 3
0
 private Item GetItem(Product product)
 {
     return Items.FirstOrDefault(i => i.Product.Id.Equals(product.Id));
 }
Esempio n. 4
0
 public Guid AddItem(Product product, DiscountRate discountRate)
 {
     Item item = GetItem(product);
     if (item.IsNull())
     {
         item = new Item(product, 1, discountRate);
         Items.Add(item);
     }
     else
         item.AddQuantity(1);
     CalculateSummary();
     return item.Id;
 }