private static void AssertExpectedTransactionsMatchActualTransactions(IReadOnlyList <AccountTransaction> actualTransactions)
        {
            Assert.AreEqual(ExpectedAccountTransactions.Count, actualTransactions.Count());

            for (int i = 0; i < ExpectedAccountTransactions.Count; i++)
            {
                TestValidationHelper.ValidateAccountTransactionsAreEqual(ExpectedAccountTransactions[i], actualTransactions[i]);
            }
        }
Exemplo n.º 2
0
        public async Task GetApplicationData_ConvertsExcelToTheCorrectApplicationData()
        {
            Account            account            = TestDataSetup.CreateAccount();
            Category           category           = TestDataSetup.CreateCategory();
            AccountTransaction accountTransaction = TestDataSetup.CreateAccountTransaction();

            var excelPackage = new ExcelPackage();

            excelPackage.Workbook.Worksheets.Add(AccountsWorksheetName);
            excelPackage.Workbook.Worksheets[AccountsWorksheetName].Cells[2, 1].Value = account.Id;
            excelPackage.Workbook.Worksheets[AccountsWorksheetName].Cells[2, 2].Value = account.Name;

            excelPackage.Workbook.Worksheets.Add(CategoriesWorksheetName);
            excelPackage.Workbook.Worksheets[CategoriesWorksheetName].Cells[2, 1].Value = category.Id;
            excelPackage.Workbook.Worksheets[CategoriesWorksheetName].Cells[2, 2].Value = category.Name;
            excelPackage.Workbook.Worksheets[CategoriesWorksheetName].Cells[2, 3].Value = category.Budgeted;

            excelPackage.Workbook.Worksheets.Add(AccountTransactionsWorksheetName);
            excelPackage.Workbook.Worksheets[AccountTransactionsWorksheetName].Cells[2, 2].Value = accountTransaction.AccountId;
            excelPackage.Workbook.Worksheets[AccountTransactionsWorksheetName].Cells[2, 3].Value = accountTransaction.Date;
            excelPackage.Workbook.Worksheets[AccountTransactionsWorksheetName].Cells[2, 4].Value = accountTransaction.Payee;
            excelPackage.Workbook.Worksheets[AccountTransactionsWorksheetName].Cells[2, 5].Value = accountTransaction.CategoryId;
            excelPackage.Workbook.Worksheets[AccountTransactionsWorksheetName].Cells[2, 6].Value = accountTransaction.Memo;
            excelPackage.Workbook.Worksheets[AccountTransactionsWorksheetName].Cells[2, 7].Value = accountTransaction.Outflow;
            excelPackage.Workbook.Worksheets[AccountTransactionsWorksheetName].Cells[2, 8].Value = accountTransaction.Inflow;

            excelFileProcessor.Setup(efp => efp.LoadExcelPackageFromFile())
            .Returns(() => excelPackage);

            ApplicationData applicationData = await excelPersistenceService.GetApplicationData();

            Assert.AreEqual(1, applicationData.Accounts.Count);
            Assert.AreEqual(1, applicationData.Categories.Count);
            Assert.AreEqual(1, applicationData.AccountTransactions.Count);

            TestValidationHelper.ValidateAccountsAreEqual(account, applicationData.Accounts.FirstOrDefault());
            TestValidationHelper.ValidateCategoriesAreEqual(category, applicationData.Categories.FirstOrDefault());
            TestValidationHelper.ValidateAccountTransactionsAreEqual(accountTransaction, applicationData.AccountTransactions.FirstOrDefault());
        }