Example #1
0
        public void TryValidate_WithNullQueryGuard_ShouldTrowExceptions()
        {
            var kernel = new GuardianKernel();

            kernel.QueryGuard = null;
            Assert.Throws <ArgumentNullException>(() =>
            {
                kernel.TryValidate();
            });
        }
        /// <summary>
        /// Guards the <see cref="DbContext"/>  by <see cref="GuardianKernel"/> .
        /// </summary>
        /// <param name="dbContext">The database context to Guard.</param>
        /// <param name="kernel">The guardian kernel.</param>
        public static DbContext UseGuardian(this DbContext dbContext, GuardianKernel kernel)
        {
            kernel.TryValidate();

            var contextHooker = new DbContextHooker(dbContext, kernel);

            contextHooker.RegisterHooks();

            return(dbContext);
        }
Example #3
0
        public void TryValidate_ShouldSuccess()
        {
            var kernel = new GuardianKernel();

            kernel.TryValidate();
        }