public void BudgetMonthView_NegativeBalanceHandling_HandlingTypeCarriedForwardOnceSet() { DateTime thisMonthDate = DateTime.Today.FirstDayOfMonth(); DateTime nextMonthDate = DateTime.Today.FirstDayOfMonth().AddMonths(1); DateTime thirdMonthDate = DateTime.Today.FirstDayOfMonth().AddMonths(2); AddTransaction(-150, 0); BudgetMonthView thisMonthView = new BudgetMonthView(TestBudget.BudgetModel, thisMonthDate); BudgetMonthView nextMonthView = new BudgetMonthView(TestBudget.BudgetModel, nextMonthDate); BudgetMonthView thirdMonthView = new BudgetMonthView(TestBudget.BudgetModel, thirdMonthDate); var mortgageThisMonth = new CategoryMonthView(_mortgage, thisMonthDate); mortgageThisMonth.CategoryMonth.NegativeBalanceHandling = NegativeBalanceHandlingTypes.CarryForwardBalance; TestBudget.SaveChanges(); Assert.That(mortgageThisMonth.CategoryMonth.NegativeBalanceHandling, Is.Not.Null); Assert.That(mortgageThisMonth.CategoryMonth.NegativeBalanceHandling, Is.EqualTo(NegativeBalanceHandlingTypes.CarryForwardBalance)); var mortgageNextMonth = new CategoryMonthView(_mortgage, nextMonthDate); Assert.That(mortgageNextMonth.CategoryMonth.NegativeBalanceHandling, Is.Null); Assert.That(mortgageNextMonth.NegativeBalanceHandling, Is.EqualTo(NegativeBalanceHandlingTypes.CarryForwardBalance)); var mortgateThirdMonth = new CategoryMonthView(_mortgage, thirdMonthDate); Assert.That(mortgateThirdMonth.CategoryMonth.NegativeBalanceHandling, Is.Null); Assert.That(mortgateThirdMonth.NegativeBalanceHandling, Is.EqualTo(NegativeBalanceHandlingTypes.CarryForwardBalance)); }
public CategoryRowViewModel(MasterCategoryRowViewModel masterCategory, Category category, BudgetEditorViewModel budgetEditor) { InitializeRelayCommands(); MasterCategory = masterCategory; _category = category; _budgetEditor = budgetEditor; _categoryMonthViews = new TransformingObservableCollection <BudgetMonthViewModel, CategoryMonthViewModel>( _budgetEditor.VisibleMonthViews, v => { //BudgetMonthView holds it's own copy of the Budget and Categories so you have to match them up based on entityId //instead of ReferenceEquals on the instance BudgetMonthView view = v.BudgetMonthView; MasterCategoryMonthView masterView = view.MasterCategories.Where(mcv => mcv.MasterCategory.EntityID == category.Parent.EntityID).Single(); var categoryMonthView = masterView.Categories.Where(c => c.Category.EntityID == _category.EntityID).SingleOrDefault(); if (categoryMonthView != null) { return(new CategoryMonthViewModel(v, this, categoryMonthView)); } else { return(new CategoryMonthViewModel(v, this, masterView, _category.EntityID)); } }, cmv => { cmv.Dispose(); }); }
public void BudgetMonthView_Overspending_Correct() { AddTransaction(-100, -1); BudgetMonthView view = new BudgetMonthView(TestBudget.BudgetModel, DateTime.Today.FirstDayOfMonth()); Assert.That(view.OverspentPreviousMonth, Is.EqualTo(-50)); Assert.That(view.AvailableToBudget, Is.EqualTo(-50)); }
public void BudgetMonthView_ValuesAreCorrect_OnInit() { BudgetMonthView view = new BudgetMonthView(TestBudget.BudgetModel, DateTime.Today.FirstDayOfMonth()); Assert.That(view.AvailableToBudget, Is.EqualTo(0)); Assert.That(view.NotBudgetedPreviousMonth, Is.EqualTo(150)); Assert.That(view.BudgetedThisMonth, Is.EqualTo(150)); Assert.That(view.AvailableToBudget, Is.EqualTo(0)); Assert.That(view.OverspentPreviousMonth, Is.EqualTo(0)); }
public MasterCategoryMonthViewModel(BudgetEditorViewModel budgetEditor, BudgetMonthViewModel budgetMonthViewModel, MasterCategoryRowViewModel masterCategoryRow, BudgetMonthView budgetMonthView, string masterCategoryId) { _budgetEditor = budgetEditor ?? throw new ArgumentNullException(nameof(budgetEditor)); _budgetMonthViewModel = budgetMonthViewModel ?? throw new ArgumentNullException(nameof(budgetMonthViewModel)); _masterCategoryRow = masterCategoryRow ?? throw new ArgumentNullException(nameof(masterCategoryRow)); _budgetMonthView = budgetMonthView ?? throw new ArgumentNullException(nameof(budgetMonthView)); _masterCategoryId = masterCategoryId ?? throw new ArgumentNullException(nameof(masterCategoryId)); RegisterForCallback(); }
public void BudgetMonthView_NegativeBalanceHandling_IsAvailableToBudgetByDefault() { DateTime thisMonthDate = DateTime.Today.FirstDayOfMonth(); DateTime nextMonthDate = DateTime.Today.FirstDayOfMonth().AddMonths(1); AddTransaction(-150, 0); BudgetMonthView thisMonthView = new BudgetMonthView(TestBudget.BudgetModel, thisMonthDate); BudgetMonthView nextMonthView = new BudgetMonthView(TestBudget.BudgetModel, nextMonthDate); var mortgageThisMonth = new CategoryMonthView(_mortgage, thisMonthDate); var mortgageNextMonth = new CategoryMonthView(_mortgage, nextMonthDate); //Negative Balance Handling is not explicit, but is assumed to be Availble To Budget By Default Assert.That(mortgageThisMonth.CategoryMonth.NegativeBalanceHandling, Is.Null); Assert.That(mortgageThisMonth.NegativeBalanceHandling, Is.EqualTo(NegativeBalanceHandlingTypes.AvailableToBudget)); }
private void MasterCategoryCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.NewItems != null) { foreach (MasterCategoryMonthView item in e.NewItems) { if (item.MasterCategory.EntityID == _masterCategoryId) { MasterCategoryMonthView = item;; _budgetMonthView.MasterCategories.CollectionChanged -= MasterCategoryCollectionChanged; _budgetMonthView = null; _masterCategoryId = null; } } } }
public void BudgetMonthView_NegativeBalanceHandling_CarryForwardBalance() { DateTime thisMonthDate = DateTime.Today.FirstDayOfMonth(); DateTime nextMonthDate = DateTime.Today.FirstDayOfMonth().AddMonths(1); AddTransaction(-150, 0); BudgetMonthView thisMonthView = new BudgetMonthView(TestBudget.BudgetModel, thisMonthDate); BudgetMonthView nextMonthView = new BudgetMonthView(TestBudget.BudgetModel, nextMonthDate); var mortgageThisMonth = new CategoryMonthView(_mortgage, thisMonthDate); mortgageThisMonth.CategoryMonth.NegativeBalanceHandling = NegativeBalanceHandlingTypes.CarryForwardBalance; TestBudget.SaveChanges(); var mortgageNextMonth = new CategoryMonthView(_mortgage, nextMonthDate); Assert.That(mortgageThisMonth.NegativeBalanceHandling, Is.EqualTo(NegativeBalanceHandlingTypes.CarryForwardBalance)); Assert.That(mortgageThisMonth.EndBalance, Is.EqualTo(-50)); Assert.That(nextMonthView.OverspentPreviousMonth, Is.EqualTo(0M)); Assert.That(mortgageNextMonth.BeginningBalance, Is.EqualTo(-50)); Assert.That(mortgageNextMonth.EndBalance, Is.EqualTo(-50)); }
private void InitializeMonthViews() { _masterCategoryMonthViews = new TransformingObservableCollection <BudgetMonthViewModel, MasterCategoryMonthViewModel>( _budgetEditor.VisibleMonthViews, v => { //BudgetMonthView holds it's own copy of the Budget and Categories so you have to match them up based on entityId //instead of ReferenceEquals on the instance BudgetMonthView view = v.BudgetMonthView; MasterCategoryMonthView masterView = view.MasterCategories.Where(mcv => mcv.MasterCategory.EntityID == _masterCategory.EntityID).SingleOrDefault(); if (masterView != null) { return(new MasterCategoryMonthViewModel(_budgetEditor, v, this, masterView)); } else { return(new MasterCategoryMonthViewModel(_budgetEditor, v, this, view, _masterCategory.EntityID)); } }, cmv => { }); }
public void Dispose() { BudgetMonthView?.Dispose(); }
public BudgetMonthViewModel(BudgetMonthView budgetMonthView) { BudgetMonthView = budgetMonthView; }