Example #1
0
        public static void Generate(this ICremaHost cremaHost, int tryCount)
        {
            var userContext    = cremaHost.GetService <IUserContext>();
            var user           = userContext.Users.Random(item => item.Authority == Authority.Admin);
            var authentication = cremaHost.Login(user.ID, "admin");

            CremaHostUtility.UserCreateTest(cremaHost, authentication, Authority.Member);
            CremaHostUtility.UserCreateTest(cremaHost, authentication, Authority.Guest);

            for (int i = 0; i < tryCount; i++)
            {
                CremaHostUtility.UserCreateTest(cremaHost, authentication);
            }

            var transaction = cremaHost.PrimaryDataBase.BeginTransaction(authentication);

            for (int i = 0; i < tryCount; i++)
            {
                CremaHostUtility.TypeCategoryCreateTest(cremaHost, authentication);
            }

            for (int i = 0; i < tryCount; i++)
            {
                CremaHostUtility.TypeCreateTest(cremaHost, authentication);
            }

            for (int i = 0; i < tryCount; i++)
            {
                CremaHostUtility.TableCategoryCreateTest(cremaHost, authentication);
            }

            for (int i = 0; i < tryCount; i++)
            {
                CremaHostUtility.TableCreateTest(cremaHost, authentication);
            }

            for (int i = 0; i < tryCount; i++)
            {
                CremaHostUtility.ChildTableCreateTest(cremaHost, authentication);
            }

            for (int i = 0; i < tryCount; i++)
            {
                CremaHostUtility.TableInheritTest(cremaHost, authentication);
            }

            for (int i = 0; i < tryCount; i++)
            {
                CremaHostUtility.ChildTableCreateTest(cremaHost, authentication);
            }

            transaction.Commit();


            //var userContext = cremaHost.GetService<IUserContext>();
            userContext.Logout(authentication, authentication.UserID);
        }
Example #2
0
        private static void CreateBase(ICremaHost cremaHost)
        {
            var authentication = cremaHost.Dispatcher.Invoke(() =>
            {
                var userContext = cremaHost.GetService <IUserContext>();
                var user        = userContext.Users.Random(item => item.Authority == Authority.Admin);
                return(cremaHost.Login(user.ID, "admin"));
            });

            if (cremaHost.PrimaryDataBase.TypeContext.Types.Any() == false)
            {
                for (int i = 0; i < 10; i++)
                {
                    CremaHostUtility.TypeCategoryCreateTest(cremaHost, authentication);
                }

                for (int i = 0; i < 10; i++)
                {
                    CremaHostUtility.TypeCreateTest(cremaHost, authentication);
                }
            }

            if (cremaHost.PrimaryDataBase.TableContext.Tables.Any() == false)
            {
                for (int i = 0; i < 10; i++)
                {
                    CremaHostUtility.TableCategoryCreateTest(cremaHost, authentication);
                }

                for (int i = 0; i < 10; i++)
                {
                    CremaHostUtility.TableCreateTest(cremaHost, authentication);
                }

                for (int i = 0; i < 10; i++)
                {
                    CremaHostUtility.ChildTableCreateTest(cremaHost, authentication);
                }

                for (int i = 0; i < 10; i++)
                {
                    CremaHostUtility.TableInheritTest(cremaHost, authentication);
                }

                for (int i = 0; i < 10; i++)
                {
                    CremaHostUtility.ChildTableCreateTest(cremaHost, authentication);
                }
            }

            cremaHost.Dispatcher.Invoke(() =>
            {
                var userContext = cremaHost.GetService <IUserContext>();
                userContext.Logout(authentication, authentication.UserID);
            });
        }