public void GetTopCategories_WhenCategoriesExist() { DbSetup(); var repositoryCore = new RepositoryCore(new LogService()); for (int i = 0; i < 10; i++) { var c = new Category(); c.Name = i.ToString(); c.Plan = i; c.Upsert(); // adding expenses for (int j = 0; j < i; j++) { var e = new Expense(); e.CategoryId = c.Id; e.Value = 10; e.Upsert(); } } var categories = repositoryCore.GetTopCategories(); Assert.IsNotNull(categories); Assert.AreEqual(5, categories.Count); Assert.IsTrue(categories.Any(c => c.Name == "9")); Assert.IsTrue(categories.Any(c => c.Name == "8")); Assert.IsTrue(categories.Any(c => c.Name == "7")); Assert.IsTrue(categories.Any(c => c.Name == "6")); Assert.IsTrue(categories.Any(c => c.Name == "5")); }
public void GetTopCategories_WhenNoCategoryExist() { DbSetup(); var repositoryCore = new RepositoryCore(new LogService()); var categories = repositoryCore.GetTopCategories(); Assert.IsNotNull(categories); Assert.AreEqual(0, categories.Count); }
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); } }