public void TestToggleCacheRole()
        {
            //SETUP
            var fakeAuthChanges = new FakeAuthChanges();
            var options         = SqliteInMemory.CreateOptions <ExtraAuthorizeDbContext>();

            using (var context = new ExtraAuthorizeDbContext(options, fakeAuthChanges))
            {
                context.Database.EnsureCreated();
                context.SeedCacheRole(true);

                var cacheRoleService = new CacheRoleService(context);
                var claims           = new List <Claim>
                {
                    new Claim(PermissionConstants.PackedPermissionClaimType,
                              new List <Permissions> {
                        Permissions.Cache1, Permissions.Cache2
                    }.PackPermissionsIntoString())
                };

                //ATTEMPT
                cacheRoleService.ToggleCacheRole();

                //VERIFY
                var role = context.RolesToPermissions.Single();
                role.RoleName.ShouldEqual(CacheRoleService.CacheRoleName);
                role.PermissionsInRole.Count().ShouldEqual(1);
                fakeAuthChanges.CacheValueSet.ShouldBeTrue();
            }
        }
        public void TestSeedCacheRole(bool hasCache2)
        {
            //SETUP
            var fakeAuthChanges = new FakeAuthChanges();
            var options         = SqliteInMemory.CreateOptions <ExtraAuthorizeDbContext>();

            using (var context = new ExtraAuthorizeDbContext(options, fakeAuthChanges))
            {
                context.Database.EnsureCreated();

                //ATTEMPT
                context.SeedCacheRole(hasCache2);
            }
            using (var context = new ExtraAuthorizeDbContext(options, fakeAuthChanges))
            {
                //VERIFY
                var role = context.RolesToPermissions.Single();
                role.RoleName.ShouldEqual(CacheRoleService.CacheRoleName);
                role.PermissionsInRole.Count().ShouldEqual(hasCache2 ? 2 : 1);
            }
        }