示例#1
0
        public void UpdateCategoryExceptionTest()
        {
            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.UpdateCategory();
        }
示例#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";
     }
 }
示例#3
0
        public void UpdateCategoryTest()
        {
            var storage           = new MemoryCategoryStorage(new RegularCategoryFactory());
            var parentCategory    = storage.CreateCategory("Parent Category", "ParentDescription", 0, null);
            var newParentCategory = storage.CreateCategory("New Parent Category", "New ParentDescription", 0, null);
            var category          = storage.CreateCategory("Test Category", "Description", 0, parentCategory);
            var viewModel         = new EditCategoryViewModel(storage, category, parentCategory)
            {
                Name           = "New Name",
                Description    = "New Description",
                ParentCategory = newParentCategory
            };

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

            Assert.IsNotNull(savedCategory);
            Assert.AreEqual(newParentCategory, viewModel.ParentCategory);
            Assert.AreEqual("New Name", savedCategory.Name);
            Assert.AreEqual("New Description", savedCategory.Description);
        }