public async Task AddInterest_Tests(decimal yearlyint, int accountid)
        {
            var account = new Account()
            {
                AccountId = 1, Balance = 10000
            };
            var command = new AddInterestCommand()
            {
                AccountId      = accountid,
                YearlyInterest = yearlyint, LatestInterest = DateTime.Now
            };

            var options = new DbContextOptionsBuilder <BankAppDataContext>()
                          .UseInMemoryDatabase(databaseName: "AddInterest_Tests")
                          .Options;

            decimal expected;

            using (var context = new BankAppDataContext(options))
            {
                context.Add(new Account()
                {
                    AccountId = 1, Balance = 10000
                });
                context.SaveChanges();
                var machine = new MachineDateTime()
                {
                };
                machine.Now = machine.Now.AddDays(30);
                var handler = new AddInterestCommandHandler(context, machine);

                expected = 10039.73m;

                await handler.Handle(command, CancellationToken.None);

                var newbalance = await context.Accounts.SingleOrDefaultAsync(a => a.AccountId == 1);

                var test = Math.Round(newbalance.Balance, 2);
                Assert.Equal(expected, test);
            }
        }
        // Chooses specific command to execute depending on the input given.
        public string Dispatch(string input)
        {
            string[] inputArgs   = input.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
            string   commandName = input.Length != 0 ? inputArgs[0].ToLower() : string.Empty;

            inputArgs = inputArgs.Skip(1).ToArray();
            string output = string.Empty;

            switch (commandName)
            {
            case "register":
                RegisterCommand register = new RegisterCommand()
                {
                    UserValidator = new UserValidator()
                };
                output = register.Execute(inputArgs);
                break;

            case "login":
                LoginCommand login = new LoginCommand();
                output = login.Execute(inputArgs);
                break;

            case "logout":
                LogoutCommand logout = new LogoutCommand();
                output = logout.Execute(inputArgs);
                break;

            case "exit":
                ExitCommand exit = new ExitCommand();
                output = exit.Execute(inputArgs);
                break;

            case "add":
                AddAccountCommand add = new AddAccountCommand()
                {
                    CheckingAccountValidator = new CheckingAccountValidator(),
                    SavingAccountValidator   = new SavingAccountValidator()
                };
                output = add.Execute(inputArgs);
                break;

            case "deposit":
                DepositCommand deposit = new DepositCommand();
                output = deposit.Execute(inputArgs);
                break;

            case "withdraw":
                WithdrawCommand withdraw = new WithdrawCommand();
                output = withdraw.Execute(inputArgs);
                break;

            // List Accounts
            case "listaccounts":
                ListAccountsCommand list = new ListAccountsCommand();
                output = list.Execute(inputArgs);
                break;

            // Deduct Fee
            case "deductfee":
                DeductFeeCommand deduct = new DeductFeeCommand();
                output = deduct.Execute(inputArgs);
                break;

            // Add Interest
            case "addinterest":
                AddInterestCommand addInterest = new AddInterestCommand();
                output = addInterest.Execute(inputArgs);
                break;

            default:
                throw new ArgumentException($"Command \"{commandName}\" not supported!");
            }

            return(output);
        }
        public string DispatchCommand(string[] commandParameters)
        {
            string commandName = commandParameters[0];

            commandParameters = commandParameters.Skip(1).ToArray();
            string          result          = string.Empty;
            SavingService   savingService   = new SavingService();
            CheckingService checkingService = new CheckingService();
            UserService     userService     = new UserService();


            switch (commandName)
            {
            case "Exit":
                ExitCommand exit = new ExitCommand();
                result = exit.Execute();
                break;

            case "Deposit":
                DepositCommand deposit = new DepositCommand(savingService);
                result = deposit.Execute(commandParameters);
                break;

            case "Withdraw":
                WithdrawCommand withdeow = new WithdrawCommand(savingService);
                result = withdeow.Execute(commandParameters);
                break;

            case "AddInterest":
                AddInterestCommand addInterest = new AddInterestCommand(savingService);
                result = addInterest.Execute(commandParameters);
                break;

            case "DeductFee":
                DeductCommand deduct = new DeductCommand(checkingService);
                result = deduct.Execute(commandParameters);
                break;

            case "Register":
                RegisterCommand register = new RegisterCommand(userService);
                result = register.Execute(commandParameters);
                break;

            case "Login":
                LoginCommand login = new LoginCommand();
                result = login.Execute(commandParameters);
                break;

            case "Logout":
                Logout logout = new Logout();
                result = logout.Execute();
                break;

            case "AddSavingAccount":
                AddSavingAccountCommand addAccount = new AddSavingAccountCommand(savingService);
                result = addAccount.Execute(commandParameters);
                break;

            case "ListAccounts":
                ListAccounts listAccounts = new ListAccounts(savingService, checkingService);
                result = listAccounts.Execute();
                break;
            }
            return(result);
        }