public void GetAccountMovmentsFromSubCategoriesFile1()
        {
            var jsonArray = TestsHelper.GetJonsArrayFromFile("TransactionsArray.json");
            List <AccountMovement> accountMovements = ModelConverter.GetAccountMovmentsFromJarray(jsonArray);

            accountMovements.Count.Should().Be(122);

            jsonArray = TestsHelper.GetJonsArrayFromFile("CategoriesArray.json");
            List <SubCategory> categorisModel = ModelConverter.GetCategoriesFromJarray(jsonArray);

            categorisModel.Count.Should().Be(105);

            var modementsViewModels = ModelConverter.CreateMovementsViewModels(accountMovements, categorisModel, "Felles");

            modementsViewModels[0].Category.Should().BeEquivalentTo("Altibox");
        }
示例#2
0
        public void CreateExcelTableFromMovementsViewModelTest()
        {
            var jsonArray = TestsHelper.GetJonsArrayFromFile("TransactionsArray.json");
            List <AccountMovement> movementsModels = ModelConverter.GetAccountMovmentsFromJarray(jsonArray);

            movementsModels.Count.Should().Be(122);

            jsonArray = TestsHelper.GetJonsArrayFromFile("CategoriesArray.json");
            List <SubCategory> categorisModel = ModelConverter.GetCategoriesFromJarray(jsonArray);

            categorisModel.Count.Should().Be(105);
            IEnumerable <string> categoryList = categorisModel.Select(cat => cat.Category).Distinct();


            var movementsViewModels = ModelConverter.CreateMovementsViewModels(movementsModels, categorisModel, "Felles");

            movementsViewModels[0].Category.Should().BeEquivalentTo("Altibox");

            ExcelWorksheet       wsSheet;
            IEnumerable <string> categories;
            ExcelPackage         excelPackage = new ExcelPackage();

            using (var stream = new MemoryStream())
                using (var package = new ExcelPackage(stream))
                {
                    package.Workbook.Worksheets.Add("Sheet1");
                    wsSheet = package.Workbook.Worksheets["Sheet1"];

                    ExcelServices.CreateExcelTableFromMovementsViewModel(movementsViewModels, wsSheet, "Transactions");


                    //now test that it generated properly, such as:
                    var sheeDefault = package.Workbook.Worksheets.FirstOrDefault();
                    if (sheeDefault != null)
                    {
                        sheeDefault.Cells["D57"].Value.Should().Be(-55);
                    }

                    var saveExcel = TestsHelper.SaveExcrlPackage(package, "test-Temp");
                    saveExcel.Should().BeTrue();
                }
        }
        public void AverageforCategoryTestMonth()
        {
            var jsonArray = TestsHelper.GetJonsArrayFromFile("TransactionsArray.json");
            List <AccountMovement> accountMovements = ModelConverter.GetAccountMovmentsFromJarray(jsonArray);

            accountMovements.Count.Should().Be(122);

            jsonArray = TestsHelper.GetJonsArrayFromFile("CategoriesArray.json");
            List <SubCategory> categorisModel = ModelConverter.GetCategoriesFromJarray(jsonArray);

            categorisModel.Count.Should().Be(105);

            var modementsViewModels = ModelConverter.CreateMovementsViewModels(accountMovements, categorisModel, "Felles");

            modementsViewModels[0].Category.Should().BeEquivalentTo("Altibox");

            var average = ModelOperation.AverageforCategory(modementsViewModels, "Mat", null, 6, true);

            average.Should().Be(117.5);
        }
示例#4
0
        public void Test2()
        {
            //Get MovementsModel
            JArray   JsonmodementsViewModels;
            Encoding encoding = Encoding.GetEncoding(28591);

            using (StreamReader stream = new StreamReader(TestsHelper.GetAssemblyFile("TransactionViewModelArray.json"), encoding, true))
            {
                JsonmodementsViewModels = JArray.Parse(stream.ReadToEnd());
            }

            var movementsViewModels = new List <MovementsViewModel>();

            foreach (var item in JsonmodementsViewModels)
            {
                movementsViewModels.Add(new ModelConverter().JsonToMovementsViewModels(item));
            }

            // Get Categories
            JArray JsonCategoryList;

            using (StreamReader stream = new StreamReader(TestsHelper.GetAssemblyFile("CategoriesArray.json"), encoding, true))
            {
                JsonCategoryList = JArray.Parse(stream.ReadToEnd());
            }
            List <string> categoryListTemp = new List <string>();

            foreach (var item in JsonCategoryList)
            {
                categoryListTemp.Add(item.ToString());
            }

            IEnumerable <string> categoryList = categoryListTemp;


            var noko  = ModelOperation.AverageforCategory(movementsViewModels, "Mat", null, 6, true);
            var noko1 = ModelOperation.AverageforCategory(movementsViewModels, "Mat", 2018, null, true);
            var noko2 = ModelOperation.AverageforCategory(movementsViewModels, "Mat", 2018, 6, true);

            noko.Should().BeGreaterThan(0);
        }
示例#5
0
        public void CreateAverageForYearMonthDayTest()
        {
            IEnumerable <string> categoryList = TestsHelper.GetCategoryList();
            var movementsViewModels           = TestsHelper.GetMovementsViewModels();

            using (var stream = new MemoryStream())
                using (var package = new ExcelPackage(stream))
                {
                    package.Workbook.Worksheets.Add("Sheet1");
                    var categoriesAverageWSheet = package.Workbook.Worksheets["Sheet1"];

                    ExcelServices.CreateAverageForYearMonthDay(movementsViewModels, categoriesAverageWSheet, categoryList, 0, 0, true);

                    //now test that it generated properly, such as:
                    //var sheeDefault = package.Workbook.Worksheets.FirstOrDefault();
                    //if (sheeDefault != null) sheeDefault.Cells["D57"].Value.Should().Be(-55);

                    var saveExcel = TestsHelper.SaveExcrlPackage(package, "CreateAverageForYearMonthDay-test");
                    saveExcel.Should().BeTrue();
                }
        }
        public void UpdateClassesTableValues()
        {
            var streamFile = TestsHelper.GetAssemblyFile("Transactions Update With Categories.xlsx");

            using (var cashflowExcelPkg = new ExcelPackage(streamFile))
            {
                IEnumerable <string> categoryList = TestsHelper.GetCategoryList();
                var expensesWSheet = cashflowExcelPkg.Workbook.Worksheets["Transactions"];

                var transactions = expensesWSheet.Tables.FirstOrDefault();
                var jsonArray    = ExcelConverter.GetJsonFromTable(transactions);
                var categoriesAverageWorkSheet  = cashflowExcelPkg.Workbook.Worksheets["Categories Average"];
                var categoriesAverageWorkSheet1 = cashflowExcelPkg.Workbook.Worksheets["Categories Average1"];
                if (categoriesAverageWorkSheet != null)
                {
                }
                jsonArray.Count.Should().Be(193);

                var noko = jsonArray.ToObject <List <MovementsViewModel> >();
                List <MovementsViewModel> movementsViewModels = JsonConvert.DeserializeObject <List <MovementsViewModel> >(jsonArray.ToString(), JsonServices.GetJsonSerializerSettings());
                movementsViewModels.Count.Should().Be(193);
            }
        }
示例#7
0
        public void Test1()
        {
            ExcelWorksheet workSheet;
            ExcelWorksheet workSheet2;

            using (Stream AccountMovmentStream = TestsHelper.GetAssemblyFile("Transactions.xlsx"))
            {
                workSheet = ExcelHelpers.GetExcelWorksheet(AccountMovmentStream, "Felles");
            }
            using (Stream SubCategoriesStream = TestsHelper.GetAssemblyFile("Categories.xlsx"))
            {
                workSheet2 = ExcelHelpers.GetExcelWorksheet(SubCategoriesStream);
            }

            var workSheet2Table      = workSheet2.Tables.FirstOrDefault();
            var workSheetTable       = workSheet.Tables.FirstOrDefault();
            var subCategoriesjArray  = ExcelConverter.GetJsonFromTable(workSheet2Table);
            var accountMovmentjArray = ExcelConverter.GetJsonFromTable(workSheetTable);
            List <SubCategory>     categorisModel   = ModelConverter.GetCategoriesFromJarray(subCategoriesjArray);
            IEnumerable <string>   categoryList     = categorisModel.Select(cat => cat.Category).Distinct();
            List <AccountMovement> accountMovements = ModelConverter.GetAccountMovmentsFromJarray(accountMovmentjArray);

            var modementsViewModels = ModelConverter.CreateMovementsViewModels(accountMovements, categorisModel, "Felles");

            var jsonModementsViewModels = JArray.Parse(JsonConvert.SerializeObject(modementsViewModels));


            jsonModementsViewModels.Should().NotBeNullOrEmpty();
            //     var filename = "Budget Cashflow Temp";
            //var path = string.Concat(@"h:\temp\");
            //Directory.CreateDirectory(path);
            //var filePath = Path.Combine(path, string.Concat(filename, ".xlsx"));
            ////excelPkg?.SaveAs(new FileInfo(filePath));

            //File.Exists(filePath).Should().BeTrue();
        }
示例#8
0
        public void UpdateTableValuesBudgetTest()
        {
            Dictionary <string, string> CategoriesAddressWithTotals = null;

            var streamFile = TestsHelper.GetAssemblyFile("Budget Cashflow.xlsx");

            using (var cashflowExcelPkg = new ExcelPackage(streamFile))
            {
                IEnumerable <string> categoryList = TestsHelper.GetCategoryList();
                var categoryListWithTotals        = Helpers.AddItemsToIenumeration(categoryList, new List <string>()
                {
                    "Sub Total", "Total"
                });
                var ExpensesWSheet = cashflowExcelPkg.Workbook.Worksheets["Expenses details"];


                var yearBudgetTable = ExpensesWSheet.Tables["Year_budget"];
                if (yearBudgetTable != null)
                {
                    CategoriesAddressWithTotals = ExcelHelpers.GetNamesAdress(categoryListWithTotals, yearBudgetTable);
                }

                var    yearWSheet   = cashflowExcelPkg.Workbook.Worksheets["Year summary"];
                var    excelTable   = yearWSheet.Tables["tblOperatingExpenses"];
                string keyCellValue = null;
                if (CategoriesAddressWithTotals != null)
                {
                    if (CategoriesAddressWithTotals.TryGetValue("Total", out keyCellValue))
                    {
                        ExcelServices.UpdateTableValues(excelTable, "BUDGET", keyCellValue);
                    }
                }
                var saveExcel = TestsHelper.SaveExcrlPackage(cashflowExcelPkg, "Update-Test1");
                saveExcel.Should().BeTrue();
            }
        }
示例#9
0
        public static List <SubCategory> GetSubCategories()
        {
            var jsonArray = TestsHelper.GetJonsArrayFromFile("CategoriesArray.json");

            return(ModelConverter.GetCategoriesFromJarray(jsonArray));
        }
示例#10
0
        public static List <AccountMovement> GetAccountMovements()
        {
            var jsonArray = TestsHelper.GetJonsArrayFromFile("TransactionsArray.json");

            return(ModelConverter.GetAccountMovmentsFromJarray(jsonArray));
        }
示例#11
0
        public void GetJonsArrayFromSubCategoriesFile()
        {
            var jsonArray = TestsHelper.GetJonsArrayFromFile("CategoriesArray.json");

            jsonArray.Count.Should().Be(105);
        }
示例#12
0
        public void GetJonsArrayFromTransactionFile()
        {
            var jsonArray = TestsHelper.GetJonsArrayFromFile("TransactionsArray.json");

            jsonArray.Count.Should().Be(122);
        }