public static async Task <IUser> GenerateUserAsync(this IUserCollection userCollection, Authentication authentication) { if (userCollection.GetService(typeof(IUserCategoryCollection)) is IUserCategoryCollection userCategoryCollection) { var category = await userCategoryCollection.GetRandomUserCategoryAsync(); return(await category.GenerateUserAsync(authentication)); } throw new NotImplementedException(); }
public async Task UsersMoved_TestAsync() { var authentication = await this.TestContext.LoginRandomAsync(Authority.Admin); var userCategoryCollection = userCollection.GetService(typeof(IUserCategoryCollection)) as IUserCategoryCollection; var userFilter = new UserFilter(); var user = await userFilter.GetUserAsync(app); var categoryFilter = new UserCategoryFilter() { ExcludedCategories = new[] { user.Category } }; var category = await categoryFilter.GetUserCategoryAsync(app); var oldCategory = user.Category; var actualPath = string.Empty; var actualCategoryPath = string.Empty; await userCollection.Dispatcher.InvokeAsync(() => { userCollection.UsersMoved += UserCollection_UsersMoved; }); await user.MoveAsync(authentication, category.Path); Assert.AreEqual(user.Path, actualPath); Assert.AreEqual(user.Category.Path, actualCategoryPath); await userCollection.Dispatcher.InvokeAsync(() => { userCollection.UsersMoved -= UserCollection_UsersMoved; }); await user.MoveAsync(authentication, oldCategory.Path); Assert.AreNotEqual(user.Path, actualPath); Assert.AreNotEqual(user.Category.Path, actualCategoryPath); void UserCollection_UsersMoved(object sender, ItemsMovedEventArgs <IUser> e) { var user = e.Items.Single(); actualPath = user.Path; actualCategoryPath = user.Category.Path; } }
public void GetService() { Console.Write(users.GetService(typeof(ICremaHost))); }