Example #1
0
 public SaleService(
     ISupplierTableRepository supplierTableRepository,
     IGoodsTableRepository goodsTableRepository,
     ISoldGoodsTableRepository soldGoodsTableRepository,
     ISaleHistoryTableRepository saleHistoryTableRepository
     )
 {
     this.supplierTableRepository    = supplierTableRepository;
     this.goodsTableRepository       = goodsTableRepository;
     this.soldGoodsTableRepository   = soldGoodsTableRepository;
     this.saleHistoryTableRepository = saleHistoryTableRepository;
 }
 public SuppliersService(ISupplierTableRepository supplierTableRepository)
 {
     this.supplierTableRepository = supplierTableRepository;
 }
Example #3
0
        public void Initialize()
        {
            supplierTableRepository = Substitute.For <ISupplierTableRepository>();
            supplierTableRepository.Get(5).Returns(new SupplierEntity()
            {
                Id      = 5,
                Name    = "John",
                Surname = "Smith"
            });
            supplierTableRepository.Get(40).Returns(new SupplierEntity()
            {
                Id      = 40,
                Name    = "Mark",
                Surname = "Deadman"
            });

            goodsTableRepository = Substitute.For <IGoodsTableRepository>();
            goodsTableRepository.FindProductsByRequest(Arg.Any <BuyArguments>())
            .Returns((callInfo) =>
            {
                var buyArguments = callInfo.Arg <BuyArguments>();

                var retVal = new List <ProductEntity>();

                foreach (var itemToBuy in buyArguments.ItemsToBuy)
                {
                    var product = this.goodsTableData.First(f => f.Name == itemToBuy.Name);

                    retVal.Add(product);
                }

                return(retVal);
            });

            this.goodsTableData = new List <ProductEntity>()
            {
                new ProductEntity()
                {
                    Id           = 1,
                    SupplierId   = 5,
                    Name         = "John's Product A",
                    Count        = 4,
                    PricePerItem = 12.5m
                },
                new ProductEntity()
                {
                    Id           = 2,
                    SupplierId   = 5,
                    Name         = "John's Product B",
                    Count        = 3,
                    PricePerItem = 12.5m
                },
                new ProductEntity()
                {
                    Id           = 3,
                    SupplierId   = 40,
                    Name         = "Mark's Product B",
                    Count        = 3,
                    PricePerItem = 12.5m
                },
                new ProductEntity()
                {
                    Id           = 4,
                    SupplierId   = 40,
                    Name         = "Pen with Blue color",
                    Count        = 3,
                    PricePerItem = 12.5m
                },
                new ProductEntity()
                {
                    Id           = 5,
                    SupplierId   = 5,
                    Name         = "Pen with Blue color",
                    Count        = 3,
                    PricePerItem = 12.5m
                }
            };

            this.soldGoodsTableRepository   = Substitute.For <ISoldGoodsTableRepository>();
            this.saleHistoryTableRepository = Substitute.For <ISaleHistoryTableRepository>();
        }