コード例 #1
0
        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();
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
 public void GetService()
 {
     Console.Write(users.GetService(typeof(ICremaHost)));
 }