Beispiel #1
0
        /// <summary>
        /// Creates an instance of a service of the specified 'T' type and initializes it with a user with the specified 'permission'.
        /// Will use any 'args' passed in instead of generating defaults.
        /// Once you create a service you can no longer add to the services collection.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="dbName"></param>
        /// <param name="permission"></param>
        /// <param name="args"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T CreateService <T>(this TestHelper helper, string dbName, Permissions permission, params object[] args) where T : IService
        {
            var user = PrincipalHelper.CreateForPermission(permission);

            return(helper.CreateService <T>(dbName, user, args));
        }
Beispiel #2
0
        /// <summary>
        /// Creates an instance of a PimsContext and initializes it with the specified 'permission'.
        /// Uses an InMemoryDatabase instead of relational.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="dbName"></param>
        /// <param name="permission"></param>
        /// <param name="ensureDeleted"></param>
        /// <returns></returns>
        public static PimsContext CreatePimsContext(this TestHelper helper, string dbName, Permissions permission, bool ensureDeleted = false)
        {
            var user = PrincipalHelper.CreateForPermission(permission);

            return(helper.CreatePimsContext(dbName, user, ensureDeleted));
        }
Beispiel #3
0
        /// <summary>
        /// Creates an instance of a controller of the specified 'T' type and initializes it with a user with the specified 'permission'.
        /// Will use any 'args' passed in instead of generating defaults.
        /// Once you create a controller you can no longer add to the services collection.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="permission"></param>
        /// <param name="uri"></param>
        /// <param name="args"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T CreateController <T>(this TestHelper helper, Permissions permission, Uri uri, params object[] args) where T : ControllerBase
        {
            var user = PrincipalHelper.CreateForPermission(permission);

            return(helper.CreateController <T>(user, uri, args));
        }
Beispiel #4
0
        /// <summary>
        /// Creates an instance of a service of the specified 'T' type and initializes it with a user with the specified 'permission'.
        /// Will use any 'args' passed in instead of generating defaults.
        /// Once you create a service you can no longer add to the services collection.
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="permission"></param>
        /// <param name="args"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T CreateRepository <T>(this TestHelper helper, Permissions permission, params object[] args) where T : IRepository
        {
            var user = PrincipalHelper.CreateForPermission(permission);

            return(helper.CreateRepository <T>(user, args));
        }