Пример #1
0
        public ActionResult Index()
        {
            var list          = _bankAccountService.GetAll();
            var listViewModel = new ListAllBankAccountsViewModel();

            foreach (var bankAccount in list)
            {
                var viewModel = new BankAccountViewModel()
                {
                    Id             = bankAccount.Id,
                    Name           = bankAccount.Name,
                    OpeningBalance = bankAccount.OpeningBalance
                };

                listViewModel.BankAccounts.Add(viewModel);
            }

            return(View(listViewModel));
        }
        public void GetAllTest()
        {
            IBankAccount acc = new BankAccount {
                BankAccountId = 1, Balance = 100
            };
            IBankAccount acc2 = new BankAccount {
                BankAccountId = 2, Balance = 110
            };

            IRepository <int, IBankAccount> repo = repoMock.Object;
            IBankAccountService             bankAccountService = new BankAccountService(repo);

            // act
            List <IBankAccount> excpectedList = new List <IBankAccount>();

            excpectedList.Add(acc);
            excpectedList.Add(acc2);
            bankAccountService.Add(acc);
            bankAccountService.Add(acc2);

            Assert.True(dataStore.Count == 2);
            Assert.Equal(excpectedList, bankAccountService.GetAll());
        }