public void CreateWalletState() { //Arrange IWalletState x; //Act x = WalletStateFactory.CreateWalletState(1, 100, 100, new List <IWalletTransactionComponent>()); //Assert Assert.IsInstanceOfType(x, typeof(WalletState)); Assert.AreEqual(1, x.WalletId); Assert.AreEqual(100m, x.CashBalance); Assert.AreEqual(100m, x.UnaccountedBalance); Assert.AreEqual(0, x.WalletTransactions.Count()); }
public void ConfirmReceiptTotal() { //Arrange IWalletState wallet; IWalletTransactionComponent cash; IEnumerable <IWalletTransactionComponent> transactions; //Act cash = WalletTransactionComponentFactory.CreateTransactionComponent(1, WalletItemTypeEnum.Cash); ((WalletReceiptableTransactionComponent)cash).Receipts.Add(new CashReceipt(50)); transactions = new List <IWalletTransactionComponent>() { cash }; wallet = WalletStateFactory.CreateWalletState(1, 100, 50, transactions); //Assert Assert.AreEqual(wallet.ReceiptTotal, 50); }
public void ConfirmCashWithdrawalTotal() { //Arrange IWalletTransactionComponent bankCard = WalletTransactionComponentFactory.CreateTransactionComponent(1, WalletItemTypeEnum.BankCard); IWalletTransactionComponent passbook = WalletTransactionComponentFactory.CreateTransactionComponent(2, WalletItemTypeEnum.Passbook); IWalletTransactionComponent chequebook = WalletTransactionComponentFactory.CreateTransactionComponent(3, WalletItemTypeEnum.Chequebook); IWalletTransactionComponent cash = WalletTransactionComponentFactory.CreateTransactionComponent(4, WalletItemTypeEnum.Cash); IWalletState actual = WalletStateFactory.CreateWalletState(1, 100, 100, new List <IWalletTransactionComponent>() { bankCard, passbook, chequebook, cash }); //Act actual.WalletTransactions.Where(o => o.WalletItemType == WalletItemTypeEnum.BankCard).SingleOrDefault().Amount = 100; actual.WalletTransactions.Where(o => o.WalletItemType == WalletItemTypeEnum.Passbook).SingleOrDefault().Amount = 100; actual.WalletTransactions.Where(o => o.WalletItemType == WalletItemTypeEnum.Chequebook).SingleOrDefault().Amount = 100; actual.WalletTransactions.Where(o => o.WalletItemType == WalletItemTypeEnum.Cash).SingleOrDefault().Amount = 100; //Assert Assert.AreEqual(actual.CashWithdrawals, 100m); }
public void ConfirmCashUnder() { //Arrange IWalletTransactionComponent bankCard = WalletTransactionComponentFactory.CreateTransactionComponent(1, WalletItemTypeEnum.BankCard); IWalletTransactionComponent passbook = WalletTransactionComponentFactory.CreateTransactionComponent(2, WalletItemTypeEnum.Passbook); IWalletTransactionComponent chequebook = WalletTransactionComponentFactory.CreateTransactionComponent(3, WalletItemTypeEnum.Chequebook); IWalletTransactionComponent cash = WalletTransactionComponentFactory.CreateTransactionComponent(4, WalletItemTypeEnum.Cash); ((WalletReceiptableTransactionComponent)cash).Receipts.Add(new CashReceipt(500)); IWalletState actual = WalletStateFactory.CreateWalletState(1, 100, 100, new List <IWalletTransactionComponent>() { bankCard, passbook, chequebook, cash }); //Act actual.WalletTransactions.Where(o => o.WalletItemType == WalletItemTypeEnum.BankCard).SingleOrDefault().Amount = 100; actual.WalletTransactions.Where(o => o.WalletItemType == WalletItemTypeEnum.Passbook).SingleOrDefault().Amount = 100; actual.WalletTransactions.Where(o => o.WalletItemType == WalletItemTypeEnum.Chequebook).SingleOrDefault().Amount = 100; actual.WalletTransactions.Where(o => o.WalletItemType == WalletItemTypeEnum.Cash).SingleOrDefault().Amount = 100; //Assert Assert.AreEqual(actual.CashDiscrepancy, -100m); }