public void BeforeEach() { _objectUnderTest = new ManageAccountsViewModel(); _closeHandlerMock = new Mock <Action>(); _objectUnderTest.Close += _closeHandlerMock.Object; }
[Authorize(Roles = RoleTypes.Admin)] //only allow admin to view all accounts public ActionResult ManageAccounts() { var VModel = new ManageAccountsViewModel(); //viewmodel to be used in form VModel.Users = _Context.Users.ToList(); //get list of users to fill model return(View(VModel)); }
public async Task <IActionResult> Index() { ManageAccountsViewModel model = new ManageAccountsViewModel() { Usernames = await _accountRepository.GetAccounts() }; return(View(model)); }
public void Should_BeZero_When_NoAccountsSelected() { Account account = new Account("NotSelected"); AccountManager.Accounts.Add(account); AccountManager.AddStatement(new Statement(1000, account), new DateTime(2000, 1, 1)); ViewModel = new ManageAccountsViewModel(AccountManager); Assert.AreEqual(0, ViewModel.NetBalance); }
public void Should_KeepListsSynchronized_After_RemovingAnAccount() { ViewModel = new ManageAccountsViewModel(AccountManager); var account = new Account("TestAccount"); ViewModel.AddAccount(account); ViewModel.RemoveAccount(ViewModel.Accounts[0]); Assert.AreEqual(0, ViewModel.AccountManager.Accounts.Count); Assert.AreEqual(0, ViewModel.Accounts.Count); }
public void Should_SumSelectedAccountBalances() { Account account = new Account("SelectedLiquid", AccountType.Liquid); Account account2 = new Account("SelectedInvested", AccountType.Invested); AccountManager.Accounts.Add(account); AccountManager.Accounts.Add(account2); AccountManager.AddStatement(new Statement(1000, account), new DateTime(2000, 1, 1)); AccountManager.AddStatement(new Statement(2300, account2), new DateTime(2001, 1, 1)); ViewModel = new ManageAccountsViewModel(AccountManager); ViewModel.SelectNetWorth(); Assert.AreEqual(3300, ViewModel.NetBalance); }
public void Should_Keep_Lists_Synchronized() { ViewModel = new ManageAccountsViewModel(AccountManager); int beforeCount = ViewModel.AccountManager.Accounts.Count; Assert.AreEqual(beforeCount, ViewModel.Accounts.Count); ViewModel.AddAccount(new Account("TestAccount")); int afterCount = ViewModel.AccountManager.Accounts.Count; Assert.AreEqual(beforeCount + 1, afterCount); Assert.AreEqual(afterCount, ViewModel.Accounts.Count); }
public void Should_SubtractBalances_When_TheyAreDebtAccounts() { Account liquid = new Account("SelectedLiquid", AccountType.Liquid); Account invested = new Account("SelectedInvested", AccountType.Invested); Account debt = new Account("Debt", AccountType.Debt); AccountManager.Accounts.Add(liquid); AccountManager.Accounts.Add(invested); AccountManager.Accounts.Add(debt); AccountManager.AddStatement(new Statement(1000, liquid), new DateTime(2000, 1, 1)); AccountManager.AddStatement(new Statement(2300, invested), new DateTime(2001, 1, 1)); AccountManager.AddStatement(new Statement(1200, debt), new DateTime(2002, 1, 1)); ViewModel = new ManageAccountsViewModel(AccountManager); ViewModel.SelectNetWorth(); Assert.AreEqual(2100, ViewModel.NetBalance); }
// GET: Accounts public ActionResult Index() { var id = User.Identity.GetUserId(); HouseHolds hh = id.GetHousehold(); var visAccounts = hh.Accounts.Where(a => a.IsSoftDeleted != true); ViewBag.recAcct = visAccounts.SelectMany(a => a.Transactions).Where(t => t.Reconciled == true).Sum(t => t.Amount); ViewBag.totAcct = visAccounts.SelectMany(a => a.Transactions).Sum(t => t.Amount); var accountsList = (from account in db.Accounts.Include("Transactions") where account.IsSoftDeleted != true && account.HouseHoldId == hh.Id let reconciledI = (from transaction in account.Transactions where transaction.Reconciled == true && transaction.Income == true select transaction.Amount).DefaultIfEmpty().Sum() let reconciledE = (from transaction in account.Transactions where transaction.Reconciled == true && transaction.Income == false select transaction.Amount) .DefaultIfEmpty().Sum() let I = (from transaction in account.Transactions where transaction.Income == true select transaction.Amount).DefaultIfEmpty().Sum() let E = (from transaction in account.Transactions where transaction.Income == false select transaction.Amount) .DefaultIfEmpty().Sum() select new ReconciledAccount { Account = account, ReconBalance = reconciledE - reconciledI, Balance = I - E }).ToList(); var model = new ManageAccountsViewModel { ReconciledAccounts = accountsList, }; //var accounts = db.Accounts.Include(a => a.HouseHold); return(View(model)); }
public void Should_SelectAllAssetAccounts() { Account liquid = new Account("Liquid", AccountType.Liquid); Account invested = new Account("Invested", AccountType.Invested); Account debt = new Account("Debt", AccountType.Debt); Account property = new Account("Property", AccountType.Property); AccountManager.Accounts.Add(liquid); AccountManager.Accounts.Add(invested); AccountManager.Accounts.Add(debt); AccountManager.Accounts.Add(property); ViewModel = new ManageAccountsViewModel(AccountManager); Assert.AreEqual(0, ViewModel.Accounts.Count(a => a.IsSelected)); ViewModel.SelectAssets(); Assert.AreEqual(3, ViewModel.Accounts.Count(a => a.IsSelected)); }
public void Should_BeZero_When_NoAccounts() { ViewModel = new ManageAccountsViewModel(AccountManager); Assert.AreEqual(0, ViewModel.NetBalance); }
public static void BankViewModel_ShouldNotBeNull() { var viewModel = new ManageAccountsViewModel(new BankViewModel()); Assert.NotNull(viewModel.BankViewModel); }
public static void TransactionType_ShouldNotBeNull() { var viewModel = new ManageAccountsViewModel(new BankViewModel()); Assert.NotNull(viewModel.TransactionType); }