Ejemplo n.º 1
0
        public void GetClientsTest(Permissions?permissions, string[] expectedClients)
        {
            //Arrange
            PermissionMemoryCache permissionMemoryCache = new PermissionMemoryCache();

            permissionMemoryCache.AddClient("client1", null);
            permissionMemoryCache.AddClient("client2", null);
            permissionMemoryCache.AddClient("client3", Permissions.ALL);
            permissionMemoryCache.AddClient("client4", Permissions.CREATE_PROJECTS | Permissions.DELETE_PROJECTS);

            //Act
            var clients = permissionMemoryCache.GetClients(permissions);

            //Assert
            //we expect these clients
            Assert.Equal(expectedClients, clients);
        }
Ejemplo n.º 2
0
        public void RemoveClientTest(string client)
        {
            //Arrange
            PermissionMemoryCache permissionMemoryCache = new PermissionMemoryCache();

            permissionMemoryCache.AddClient("client1", null);
            permissionMemoryCache.AddClient("client2", null);
            permissionMemoryCache.AddClient("client3", Permissions.ALL);
            permissionMemoryCache.AddClient("client4", Permissions.CREATE_PROJECTS | Permissions.DELETE_PROJECTS);

            //Act
            permissionMemoryCache.RemoveClient(client);

            //get all clients
            var clients = permissionMemoryCache.GetClients(null).ToList();

            //Assert
            //we expect these clients
            Assert.DoesNotContain(client, clients);
            Assert.Equal(3, clients.Count);
        }
Ejemplo n.º 3
0
 public ChatHub(PermissionMemoryCache permissionMemoryCache, UserManager <User> userManager, RoleManager <Role> roleManager)
 {
     _permissionMemoryCache = permissionMemoryCache;
     _userManager           = userManager;
     _roleManager           = roleManager;
 }
Ejemplo n.º 4
0
 public void SetDependencies(IHubContext <ChatHub> hubContext, PermissionMemoryCache permissionMemoryCache)
 {
     _hubContext            = hubContext;
     _permissionMemoryCache = permissionMemoryCache;
 }