public void Constructor_ValidModel_ExpectPresentation()
        {
            var budgetItem = new BudgetItem("id", "name", 100.42m, BudgetItemType.Debt);
            var viewModel  = new BudgetItemViewModel(budgetItem);

            viewModel.Name.Should().Be(budgetItem.Name);
            viewModel.Amount.Should().Be(budgetItem.Amount.ToCurrencyString());
        }
        public void Name_Set_ExpectPropertyChanged()
        {
            var budgetItem = new BudgetItem("id", "name");
            var viewModel  = new BudgetItemViewModel(budgetItem);

            string newName    = "new name";
            bool   wasChanged = false;

            viewModel.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(viewModel.Name))
                {
                    wasChanged = true;
                }
            };

            viewModel.Name = newName;
            wasChanged.Should().BeTrue();
        }
        public void Amount_Set_ExpectPropertyChanged()
        {
            var budgetItem = new BudgetItem("id", "name");
            var viewModel  = new BudgetItemViewModel(budgetItem);

            decimal newAmount  = -220m;
            bool    wasChanged = false;

            viewModel.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(viewModel.Amount))
                {
                    wasChanged = true;
                }
            };

            viewModel.Amount = newAmount.ToCurrencyString();
            wasChanged.Should().BeTrue();
        }
Esempio n. 4
0
 public void AddNewBudgetItem()
 {
     var newItem = new BudgetItem("id", NewBudgetItemName, type: DefaultItemType);
 }
Esempio n. 5
0
        // Helper method
        public void AddNewBudgetItem()
        {
            var newItem = new BudgetItem(NewBudgetItemName, DefaultItemType);

            BudgetItems.Add(newItem);
        }