public async Task TestAddRoleToUseTrigger()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <ExtraAuthorizeDbContext>();

            using (var context = new ExtraAuthorizeDbContext(options, new AuthChanges()))
            {
                context.Database.EnsureCreated();
                var rolToPer = RoleToPermissions.CreateRoleWithPermissions
                                   ("test", "test", new List <Permissions> {
                    Permissions.AccessAll
                }, context).Result;
                context.Add(rolToPer);
                context.SaveChanges();

                //ATTEMPT
                var userToRole = new UserToRole("test", rolToPer);
                context.Add(userToRole);
                await context.SaveChangesAsync();

                //VERIFY
                context.TimeStores.Count().ShouldEqual(1);
                context.UserToRoles.Count().ShouldEqual(1);
            }
        }
Ejemplo n.º 2
0
        public async Task TestSaveChangesAsyncOk()
        {
            //SETUP
            var options = this.CreateUniqueClassOptions <ExtraAuthorizeDbContext>();

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

                //ATTEMPT
                var entity = RoleToPermissions.CreateRoleWithPermissions(Guid.NewGuid().ToString(), "description",
                                                                         new List <Permissions> {
                    Permissions.Cache1
                }, context).Result;
                context.Add(entity);
                var numWritten = await context.SaveChangesAsync();

                //VERIFY
                numWritten.ShouldEqual(1);
            }
        }