Example #1
0
        public void Constructor_ValidParams_ExpectAssignment()
        {
            string colorKey           = "color key";
            string iconSource         = "icon path";
            string description        = "a description";
            string subtitle           = "great subtitle";
            string addItemText        = "different text in the add item area";
            string customTitle        = "a custom title";
            bool   hasSecondaryHeader = true;
            bool   hasDateOnHeader    = true;

            BudgetGroupPresentation presentation = new BudgetGroupPresentation(
                colorKey,
                iconSource,
                description,
                subtitle,
                addItemText,
                customTitle,
                hasSecondaryHeader,
                hasDateOnHeader);

            presentation.ColorKey.Should().Be(colorKey);
            presentation.IconSource.Should().Be(iconSource);
            presentation.Description.Should().Be(description);
            presentation.Subtitle.Should().BeEquivalentTo(subtitle);
            presentation.AddItemText.Should().Be(addItemText);
            presentation.CustomTitle.Should().Be(customTitle);
            presentation.HasSecondaryHeader.Should().Be(hasSecondaryHeader);
            presentation.HasDateOnHeader.Should().Be(hasDateOnHeader);
        }
Example #2
0
        public BudgetGroupViewModel(BudgetGroup budgetGroup)
        {
            BudgetGroup  = budgetGroup ?? throw new ArgumentNullException(nameof(budgetGroup));
            presentation = BudgetGroupPresentationBuilder.Build(budgetGroup);

            budgetGroup.BudgetItems.ToList().ForEach(item => AddBudgetItemViewModel(item));
            budgetGroup.BudgetItems.CollectionChanged += BudgetItemsChanged;

            budgetGroup.PropertyChanged += (o, e) => PropertyChanged?.Invoke(this, e); // NOTE: this only works as the names in this VM are the same as the model
        }
Example #3
0
 public BudgetGroupViewModel(BudgetGroup budgetGroup)
 {
     BudgetGroup  = budgetGroup;
     presentation = new BudgetGroupPresentation();
     budgetGroup.BudgetItems.CollectionChanged += BudgetItemChanged;
     budgetGroup.BudgetItems.ToList().ForEach(item =>
     {
         var viewModel = new BudgetItemViewModel(item);
         BudgetItems.Add(viewModel);
     });
     budgetGroup.PropertyChanged += (o, e) => PropertyChanged?.Invoke(this, e);
 }
Example #4
0
        public void Constructor_DefaultValues_ExpectAssignment()
        {
            BudgetGroupPresentation presentation = new BudgetGroupPresentation();

            presentation.ColorKey.Should().Be(BudgetGroupPresentation.DefaultColorKey);
            presentation.IconSource.Should().Be("");
            presentation.Description.Should().Be("");
            presentation.Subtitle.Should().BeEquivalentTo(BudgetGroupPresentation.DefaultSubtitle);
            presentation.AddItemText.Should().Be(BudgetGroupPresentation.DefaultAddItemText);
            presentation.CustomTitle.Should().Be("");
            presentation.HasSecondaryHeader.Should().Be(false);
            presentation.HasDateOnHeader.Should().Be(false);
        }
Example #5
0
        public void Constructor_ValidateParameters_ExpectAssignment()
        {
            var budgetItems = new List <BudgetItem> {
                new BudgetItem("id", "name", 100.3m, BudgetItemType.Income)
            };
            var presentation = new BudgetGroupPresentation();

            var budgetGroup = new BudgetGroup("id", "name", budgetItems: budgetItems);

            budgetGroup.Id.Should().Be("id");
            budgetGroup.Name.Should().Be("name");
            budgetGroup.BudgetItems.Should().BeEquivalentTo(budgetItems);
        }