Exemplo n.º 1
0
        public void CreateNewCategoryTest()
        {
            var storage        = new MemoryCategoryStorage(new RegularCategoryFactory());
            var parentCategory = storage.CreateCategory("Parent Category", "ParentDescription", 0, null);
            var viewModel      = new EditCategoryViewModel(storage, null, parentCategory)
            {
                Name        = "Name",
                Description = "Description"
            };

            viewModel.CreateNewCategory();
            var savedCategory = storage.GetAllCategories().FirstOrDefault(x => x.Name.Equals("Name"));

            Assert.IsNotNull(savedCategory);
            Assert.AreEqual(parentCategory, viewModel.ParentCategory);
            Assert.AreEqual("Name", savedCategory.Name);
            Assert.AreEqual("Description", savedCategory.Description);
        }
Exemplo n.º 2
0
 public EditCategory(ICategory category = null, ICategory parent = null)
 {
     this.InitializeComponent();
     if (category == null)
     {
         ViewModel           = new EditCategoryViewModel(MainPage.GlobalSettings.Storages.CategoryStorage, category, parent);
         _saveCategoryAction = delegate { ViewModel.CreateNewCategory(); };
         Title               = "Create Category";
         PrimaryButtonText   = "Create Category";
         SecondaryButtonText = "Cancel";
     }
     else
     {
         ViewModel           = new EditCategoryViewModel(MainPage.GlobalSettings.Storages.CategoryStorage, category, category);
         _saveCategoryAction = delegate { ViewModel.UpdateCategory(); };
         Title               = "Edit Category";
         PrimaryButtonText   = "Edit Category";
         SecondaryButtonText = "Cancel";
     }
 }