public void GetQueriesAsDefaultTenant()
        {
            var factory = new SystemAccessRuleQueryFactory();
            var queries = factory.GetQueries();

            Assert.IsNotNull(queries, "The system access queries should not be null.");
            Assert.AreNotEqual(0, queries.Count, "The count of system access queries should not be 0.");

            using (new SecurityBypassContext())
            {
                // Verify the system rules
                foreach (var kvp in queries)
                {
                    var subjectPermission = kvp.Key;
                    var accessRuleQueries = kvp.Value;

                    Assert.IsNotNull(Entity.Get <Subject>(subjectPermission.SubjectId), "The subject does not exist.");
                    Assert.IsNotNull(Entity.Get <Permission>(subjectPermission.PermissionId), "The permission does not exist.");

                    foreach (var accessRuleQuery in accessRuleQueries)
                    {
                        Assert.IsNotNull(Entity.Get <EntityType>(accessRuleQuery.ControlsAccessForTypeId), "The entity types does not exist.");
                        Assert.IsNotNull(accessRuleQuery.Query, "The query should not be null.");

                        QueryResult result = Factory.QueryRunner.ExecuteQuery(accessRuleQuery.Query, new QuerySettings()
                        {
                            SecureQuery = false
                        });
                        Assert.AreNotEqual(0, result.Columns.Count, "The number of columns is invalid");
                        Assert.IsTrue(result.Columns[0].ColumnType is IdentifierType, "The column type is invalid.");
                    }
                }
            }
        }
        public void GetQueriesNoRequestContextSet()
        {
            var factory = new SystemAccessRuleQueryFactory();

            Assert.That(() =>
                        factory.GetQueries(),
                        Throws.TypeOf <InvalidOperationException>().And.Message.EqualTo("RequestContext not set."));
        }