public async Task CategoriesDeleted_TestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var categoryFilter = new UserCategoryFilter() { HasParent = true, IsLeaf = true }; var category1 = await categoryFilter.GetUserCategoryAsync(app); var expectedPath = category1.Path; var actualPath = string.Empty; await userCategoryCollection.AddCategoriesDeletedEventHandlerAsync(UserCategoryCollection_CategoriesDeleted); await category1.DeleteAsync(authentication); Assert.AreEqual(expectedPath, actualPath); await userCategoryCollection.RemoveCategoriesDeletedEventHandlerAsync(UserCategoryCollection_CategoriesDeleted); var category2 = await categoryFilter.GetUserCategoryAsync(app); await category2.DeleteAsync(authentication); Assert.AreEqual(expectedPath, actualPath); void UserCategoryCollection_CategoriesDeleted(object sender, ItemsDeletedEventArgs <IUserCategory> e) { actualPath = e.ItemPaths.Single(); } }
public async Task Deleted_TestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var userCategoryFilter = new UserCategoryFilter() { HasParent = true, IsLeaf = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var actualCategory = userCategory; await userCategory.Dispatcher.InvokeAsync(() => { userCategory.Deleted += UserCategory_Deleted; }); await userCategory.DeleteAsync(authentication); Assert.IsNull(actualCategory); void UserCategory_Deleted(object sender, EventArgs e) { if (sender is IUserCategory userCategory) { actualCategory = null; } } }
public async Task ItemsDeleted_UserCategory_TestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var userCategoryFilter1 = new UserCategoryFilter() { HasParent = true, IsLeaf = true }; var userItem1 = (await userCategoryFilter1.GetUserCategoryAsync(app)) as IUserItem; var actualPath = string.Empty; var expectedPath = userItem1.Path; await userContext.AddItemsDeletedEventHandlerAsync(UserContext_ItemsDeleted); await userItem1.DeleteAsync(authentication); Assert.AreEqual(expectedPath, actualPath); await userContext.RemoveItemsDeletedEventHandlerAsync(UserContext_ItemsDeleted); var userCategoryFilter2 = new UserCategoryFilter() { HasParent = true, IsLeaf = true }; var userItem2 = (await userCategoryFilter2.GetUserCategoryAsync(app)) as IUserItem; await userItem2.DeleteAsync(authentication); Assert.AreEqual(expectedPath, actualPath); void UserContext_ItemsDeleted(object sender, ItemsDeletedEventArgs <IUserItem> e) { var userItem = e.Items.Single(); actualPath = e.ItemPaths.Single(); } }
public async Task DeleteAsync_Arg0_Null_FailTestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasParent = true, IsLeaf = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); await userCategory.DeleteAsync(null); }
public async Task Name_TestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); Assert.AreNotEqual(string.Empty, userCategory.Name); }
public async Task Parent_TestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); Assert.IsNotNull(userCategory.Parent); }
public async Task DeleteAsync_Expired_FailTestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasParent = true, IsLeaf = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); await userCategory.DeleteAsync(expiredAuthentication); }
public async Task Path_TestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); NameValidator.ValidateCategoryPath(userCategory.Path); }
public async Task RenameAsync_Arg0_Null_FailTestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var name = RandomUtility.NextName(); await userCategory.RenameAsync(null, name); }
public async Task RenameAsync_Expired_FailTestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var name = RandomUtility.NextName(); await userCategory.RenameAsync(expiredAuthentication, null); }
public async Task DeleteAsync_HasUsers_FailTestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var userCategoryFilter = new UserCategoryFilter() { HasParent = true, HasUsers = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); await userCategory.DeleteAsync(authentication); }
public async Task AddNewCategoryAsync_Arg1_Empty_TestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); await userCategory.AddNewCategoryAsync(authentication, string.Empty); }
public async Task AddNewCategoryAsync_Expired_TestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var name = await userCategory.GenerateNewCategoryNameAsync(RandomUtility.NextName()); await userCategory.AddNewCategoryAsync(expiredAuthentication, name); }
public async Task DeleteAsync_Guest_PermissionDenied_FailTestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Guest); var userCategoryFilter = new UserCategoryFilter() { HasParent = true, IsLeaf = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); await userCategory.DeleteAsync(authentication); }
public async Task AddNewCategoryAsync_Arg0_Null_TestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var name = await userCategory.GenerateNewCategoryNameAsync(RandomUtility.NextName()); await userCategory.AddNewCategoryAsync(null, name); }
public async Task MoveAsync_Arg1_Null_FailTestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); await userCategory.MoveAsync(authentication, null); }
public async Task MoveAsync_Root_FailTestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var userCategory = userCategoryCollection.Root; var parentCategoryFilter = new UserCategoryFilter() { HasParent = true }; var parentCategory = await parentCategoryFilter.GetUserCategoryAsync(app); await userCategory.MoveAsync(authentication, parentCategory.Path); }
public async Task IndexerTest_Dispatcher_FailTestAsync() { var categoryFilter = new UserCategoryFilter() { HasParent = true }; var category1 = await categoryFilter.GetUserCategoryAsync(app); var categoryPath = category1.Path; var category2 = userCategoryCollection[categoryPath]; Assert.Fail(); }
public async Task Contains_TestAsync() { var categoryFilter = new UserCategoryFilter() { HasParent = true }; var category = await categoryFilter.GetUserCategoryAsync(app); var categoryPath = category.Path; var contains = userCategoryCollection.Dispatcher.Invoke(() => userCategoryCollection.Contains(categoryPath)); Assert.IsTrue(contains); }
public async Task Indexer_TestAsync() { var categoryFilter = new UserCategoryFilter() { HasParent = true }; var category1 = await categoryFilter.GetUserCategoryAsync(app); var categoryPath = category1.Path; var category2 = userCategoryCollection.Dispatcher.Invoke(() => userCategoryCollection[categoryPath]); Assert.AreEqual(category1, category2); }
public async Task Indexer_Arg0_Nonexistent_FailTestAsync() { var categoryFilter = new UserCategoryFilter() { HasParent = true }; var category = await categoryFilter.GetUserCategoryAsync(app); var name = await category.GenerateNewCategoryNameAsync(); var categoryName = new CategoryName(category.Path, name); await userCategoryCollection.Dispatcher.InvokeAsync(() => userCategoryCollection[categoryName]); }
public async Task RenameAsync_Arg1_InvalidName_FailTestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var name = RandomUtility.NextInvalidName(); await userCategory.RenameAsync(authentication, name); }
public async Task RenameAsync_Guest_PermissionDenied_FailTestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Guest); var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var name = RandomUtility.NextName(); await userCategory.RenameAsync(authentication, name); }
public async Task Contains_Dispatcher_FailTestAsync() { var categoryFilter = new UserCategoryFilter() { HasParent = true }; var category = await categoryFilter.GetUserCategoryAsync(app); var categoryPath = category.Path; userCategoryCollection.Contains(categoryPath); Assert.Fail(); }
public async Task Users_Dispatcher_TestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasUsers = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); foreach (var item in userCategory.Users) { Assert.Fail(); } }
public async Task CategoriesMoved_TestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var categoryFilter = new UserCategoryFilter() { HasParent = true }; var category = await categoryFilter.GetUserCategoryAsync(app); var parentFilter = new UserCategoryFilter() { CategoryToMove = category }; var parent1 = await parentFilter.GetUserCategoryAsync(app); var expectedPath = new CategoryName(parent1.Path, category.Name); var actualPath = string.Empty; await userCategoryCollection.AddCategoriesMovedEventHandlerAsync(UserCategoryCollection_CategoriesMoved); await category.MoveAsync(authentication, parent1.Path); Assert.AreEqual(expectedPath, actualPath); await userCategoryCollection.RemoveCategoriesMovedEventHandlerAsync(UserCategoryCollection_CategoriesMoved); var parent2 = await parentFilter.GetUserCategoryAsync(app); await category.MoveAsync(authentication, parent2.Path); Assert.AreEqual(expectedPath, actualPath); void UserCategoryCollection_CategoriesMoved(object sender, ItemsMovedEventArgs <IUserCategory> e) { var category = e.Items.Single(); actualPath = category.Path; } }
public async Task MoveAsync_ToChild_FailTestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var userCategoryFilter = new UserCategoryFilter() { HasParent = true, HasCategories = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var parentCategory = await userCategory.Dispatcher.InvokeAsync(() => userCategory.Categories.Random()); await userCategory.MoveAsync(authentication, parentCategory.Path); }
public async Task AddNewCategoryAsync_Guest_PermissionDenied_TestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Member); var userCategoryFilter = new UserCategoryFilter() { HasParent = true, HasCategories = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var name = await userCategory.Dispatcher.InvokeAsync(() => userCategory.Categories.Random().Name); await userCategory.AddNewCategoryAsync(authentication, name); }
public async Task AddNewUserAsync_Expired_TestAsync() { var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var userID = await userCollection.GenerateNewUserIDAsync(); var authority = userContext.GetRandomAuthority(); var password = userContext.GetPassword(authority); var userName = RandomUtility.NextName(); await userCategory.AddNewUserAsync(expiredAuthentication, userID, password, userName, authority); }
public async Task RenameAsync_TestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var userCategoryFilter = new UserCategoryFilter() { HasParent = true }; var userCategory = await userCategoryFilter.GetUserCategoryAsync(app); var name = RandomUtility.NextName(); await userCategory.RenameAsync(authentication, name); Assert.AreEqual(name, userCategory.Name); }