public async Task CategoriesCreated_TestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var parent = await userCategoryCollection.GetRandomUserCategoryAsync(); var expectedName = await parent.GenerateNewCategoryNameAsync(); var expectedPath = new CategoryName(parent.Path, expectedName); var actualName = string.Empty; var actualPath = string.Empty; await userCategoryCollection.AddCategoriesCreatedEventHandlerAsync(UserCategoryCollection_CategoriesCreated); var category1 = await parent.AddNewCategoryAsync(authentication, expectedName); Assert.AreEqual(expectedName, actualName); Assert.AreEqual(expectedPath, actualPath); await userCategoryCollection.RemoveCategoriesCreatedEventHandlerAsync(UserCategoryCollection_CategoriesCreated); var category2 = parent.GenerateUserCategoryAsync(authentication); Assert.AreEqual(expectedName, actualName); Assert.AreEqual(expectedPath, actualPath); void UserCategoryCollection_CategoriesCreated(object sender, ItemsCreatedEventArgs <IUserCategory> e) { var category = e.Items.Single(); actualName = category.Name; actualPath = category.Path; } }