public TransactionService( IClientTableRepository clientTableRepository, IClientSharesTableRepository clientSharesTableRepository, ISharesTableRepository sharesTableRepository, ITransactionHistoryTableRepository transactionHistoryTableRepository ) { this.clientTableRepository = clientTableRepository; this.clientSharesTableRepository = clientSharesTableRepository; this.sharesTableRepository = sharesTableRepository; this.transactionHistoryTableRepository = 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); }