示例#1
0
        public async Task ExecutePrivileged()
        {
            var requirements = new RequirementCollection();

            requirements.RequirePrivileges(DbObjectType.Table, ObjectName.Parse("sys.tab1"), Privileges.Insert);

            SqlStatement statement = new TestStatement {
                Requirements = requirements,
                Location     = new LocationInfo(0, 0)
            };

            statement = statement.Prepare(context);

            await statement.ExecuteAsync(context);
        }
示例#2
0
        public async Task ExecuteWithBadprivileges()
        {
            var requirements = new RequirementCollection();

            requirements.RequirePrivileges(DbObjectType.Table, ObjectName.Parse("sys.tab1"), Privileges.Alter);

            SqlStatement statement = new TestStatement {
                Requirements = requirements,
                Location     = new LocationInfo(0, 0)
            };

            statement = statement.Prepare(context);

            await Assert.ThrowsAnyAsync <UnauthorizedAccessException>(() => statement.ExecuteAsync(context));
        }