public TransactionService( IClientTableRepository clientTableRepository, IClientSharesTableRepository clientSharesTableRepository, ISharesTableRepository sharesTableRepository, ITransactionHistoryTableRepository transactionHistoryTableRepository ) { this.clientTableRepository = clientTableRepository; this.clientSharesTableRepository = clientSharesTableRepository; this.sharesTableRepository = sharesTableRepository; this.transactionHistoryTableRepository = transactionHistoryTableRepository; }
public TransactionService(IClientTableRepository clientTableRepository, IStockTableRepository stockTableRepository, IStockOfClientsTableRepository stockClientTableRepository, ITransactionHistoryTableRepository transactionHistoryTableRepository, EditCleintStockService editCleintStockService) { this.clientTableRepository = clientTableRepository; this.stockTableRepository = stockTableRepository; this.stockClientTableRepository = stockClientTableRepository; this.transactionHistoryTableRepository = transactionHistoryTableRepository; this.editCleintStockService = editCleintStockService; }
public void Initialize() { this.clientTableRepository = Substitute.For <IClientTableRepository>(); this.stockTableRepository = Substitute.For <IStockTableRepository>(); this.stockOfClientsTableRepository = Substitute.For <IStockOfClientsTableRepository>(); this.transactionHistoryTableRepository = Substitute.For <ITransactionHistoryTableRepository>(); this.editCleintStockService = new EditCleintStockService(this.stockOfClientsTableRepository); this.clientTableRepository.Get(5).Returns(new ClientEntity() { ID = 5, Name = "Serj", Surname = "Tankian", PhoneNumber = "+7228133705", AccountBalance = 100, }); this.clientTableRepository.Get(32).Returns(new ClientEntity() { ID = 32, Name = "Chester", Surname = "Bennington", PhoneNumber = "+7228133705", AccountBalance = 50 }); this.stockTableRepository.Get(1).Returns(new StockEntity() { ID = 1, Name = "Yandex", Type = "P", Cost = 10 }); this.stockOfClientsTableRepository.Get(2).Returns(new StockOfClientsEntity() { ID = 2, ClientID = 32, StockID = 1, Amount = 5 }); this.stockTableRepository.GetCost(Arg.Is <int>(1)).Returns(10); this.stockOfClientsTableRepository.GetAmount( Arg.Is <int>(5), Arg.Is <int>(1)).Returns(0); this.stockOfClientsTableRepository.GetAmount( Arg.Is <int>(32), Arg.Is <int>(1)).Returns(10); this.clientTableRepository.GetBalance(Arg.Is <int>(5)).Returns(100); this.clientTableRepository.GetBalance(Arg.Is <int>(32)).Returns(50); this.stockTableRepository.GetType(Arg.Is <int>(1)).Returns("P"); }
public TransactionHistoryService(ITransactionHistoryTableRepository transactionHistoryTableRepository) { this.transactionHistoryTableRepository = transactionHistoryTableRepository; }
public void Initialize() { transactionHistoryTableRepository = Substitute.For <ITransactionHistoryTableRepository>(); transactionHistoryService = new TransactionHistoryService(transactionHistoryTableRepository); }
public void Initialize() { clientTableRepository = Substitute.For <IClientTableRepository>(); sharesTableRepository = Substitute.For <ISharesTableRepository>(); clientSharesTableRepository = Substitute.For <IClientSharesTableRepository>(); transactionHistoryTableRepository = Substitute.For <ITransactionHistoryTableRepository>(); clientTableRepository.ContainsById(1).Returns(true); clientTableRepository.ContainsById(2).Returns(true); clientTableRepository.ContainsById(3).Returns(false); sharesTableRepository.ContainsById(1).Returns(true); sharesTableRepository.ContainsById(2).Returns(true); sharesTableRepository.ContainsById(3).Returns(true); sharesTableRepository.ContainsById(4).Returns(false); clientTableRepository.GetById(1).Returns(new ClientEntity() { Id = 1, Balance = 0M, Name = "Seller", Portfolio = new List <ClientSharesEntity>() { new ClientSharesEntity() { Id = 1, Quantity = 50, Shares = new SharesEntity { Id = 1, Price = 10M, SharesType = "TypeA" } }, new ClientSharesEntity() { Id = 2, Quantity = 10, Shares = new SharesEntity { Id = 3, Price = 15M, SharesType = "TypeC" } } } }); clientTableRepository.GetById(2).Returns(new ClientEntity() { Id = 2, Balance = 100M, Name = "Buyer", Portfolio = new List <ClientSharesEntity>() { new ClientSharesEntity() { Id = 2, Quantity = 0, Shares = new SharesEntity { Id = 2, Price = 5M, SharesType = "TypeB" } }, new ClientSharesEntity() { Id = 3, Quantity = 15, Shares = new SharesEntity { Id = 1, Price = 10M, SharesType = "TypeA" } } } }); sharesTableRepository.GetById(1).Returns(new SharesEntity() { Id = 1, Price = 10M, SharesType = "TypeA" }); sharesTableRepository.GetById(2).Returns(new SharesEntity() { Id = 2, Price = 5M, SharesType = "TypeB" }); sharesTableRepository.GetById(3).Returns(new SharesEntity() { Id = 3, Price = 15M, SharesType = "TypeC" }); transactionService = new TransactionService( clientTableRepository, clientSharesTableRepository, sharesTableRepository, transactionHistoryTableRepository); }