コード例 #1
0
        public void GetExpenses_WhenNoExpensesExist()
        {
            DbSetup();
            var repositoryCore = new RepositoryCore(new LogService());

            var expeneses = repositoryCore.GetExpenses();

            Assert.IsNotNull(expeneses);
            Assert.AreEqual(0, expeneses.Count);
        }
コード例 #2
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);
            NavigationItem.Title       = StaticValues.ExpenseListNavigationItemTitle;
            ParentViewController.Title = StaticValues.ExpenseListNavigationTitle;
            var repository = new RepositoryCore(CoreUtilities.GetLogService());
            var expenses   = repository.GetExpenses();
            var listSource = new ExpenseListSource(expenses, this);

            TableView.Source = listSource;
            TableView.ReloadData();
        }
コード例 #3
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            ParentViewController.Title = StaticValues.ReportNavigationTitle;

            foreach (var view in View.Subviews)
            {
                view.RemoveFromSuperview();
            }

            SFChart chart = new SFChart();

            chart.Frame = this.View.Frame;

            chart.Legend.Visible = true;

            SFCategoryAxis primaryAxis = new SFCategoryAxis();

            chart.PrimaryAxis             = primaryAxis;
            chart.ColorModel.Palette      = SFChartColorPalette.Custom;
            chart.ColorModel.CustomColors = NSArray.FromObjects(StaticValues.DarkBlue, StaticValues.LightBlue);


            var repository    = new RepositoryCore(CoreUtilities.GetLogService());
            var topCategories = repository.GetTopCategories();
            var totalExpense  = repository.GetExpenses();
            var averageSpent  = totalExpense.Count == 0 ? 0 : totalExpense.Average(e => e.Value);

            if (topCategories.Count > 0)
            {
                var dataModel = new ReportChartDataSource(topCategories, averageSpent);
                chart.DataSource = dataModel as SFChartDataSource;

                this.View.AddSubview(chart);
                chart.Frame = new RectangleF(10, 70, (float)View.Bounds.Width - 10, (float)View.Bounds.Height - 160);
            }
        }
コード例 #4
0
        public void GetExpenses_WhenExpensesExist()
        {
            DbSetup();
            var db             = new SQLiteConnection(new SQLitePlatformIOS(), _dbPath);
            var repositoryCore = new RepositoryCore(new LogService());
            var category       = new Category();

            category.Name = "test";
            category.Plan = 45;
            category.Upsert();

            var beginingOfMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1, 1, 1, 1);

            db.Insert(new Expense()
            {
                CategoryId = category.Id, Value = 230, Description = "for unit test"
            });
            db.Insert(new Expense()
            {
                CategoryId = category.Id, Value = 230, ExpenseDate = DateTime.Now.AddMonths(-1)
            });
            db.Insert(new Expense()
            {
                CategoryId = category.Id, Value = 230, ExpenseDate = beginingOfMonth
            });
            db.Insert(new Expense()
            {
                CategoryId = category.Id, Value = 230, ExpenseDate = beginingOfMonth.AddHours(-2)
            });

            var expenses = repositoryCore.GetExpenses();

            Assert.IsNotNull(expenses);
            Assert.AreEqual(2, expenses.Count);
            Assert.AreEqual(230, expenses.Where(e => e.Description == "for unit test").First().Value);
        }