Ejemplo n.º 1
0
        public void Load_CallTwiceWithTheSameDataInTheSameRoleOrder_OnlyOnceCallsStore()
        {
            var sut   = new PermissionCache();
            var count = 0;
            var roles = new List <string> {
                "Role1", "Role2"
            };
            var permission = new ResourcePermissionKey
            {
                PermissionId = 1,
                ResourceId   = 2
            };
            var instance = "0";

            sut.Load(() => { count++; return(true); }, roles, permission, instance);
            sut.Load(() => { count++; return(true); }, roles, permission, instance);
            Assert.AreEqual(1, count);
        }
Ejemplo n.º 2
0
        public void Clear_CallTwiceWithTheSameDataInDifferentRoleOrder_OnlyOnceCallsStore(string clearedRole, int expectedCalls)
        {
            var sut   = new PermissionCache();
            var count = 0;
            var roles = new List <string> {
                "Role1", "Role2"
            };
            var permission = new ResourcePermissionKey
            {
                PermissionId = 1,
                ResourceId   = 2
            };
            var instance = "0";

            sut.Load(() => { count++; return(true); }, roles, permission, instance);
            sut.Clear(clearedRole, permission);
            sut.Load(() => { count++; return(true); }, roles, permission, instance);
            Assert.AreEqual(expectedCalls, count);
        }
Ejemplo n.º 3
0
        public void Load_CallOnce_LoadDataFromStore()
        {
            var sut   = new PermissionCache();
            var count = 0;
            var roles = new List <string> {
                "Role1", "Role2"
            };
            var permission = new ResourcePermissionKey
            {
                PermissionId = 1,
                ResourceId   = 2
            };
            var instance = "0";

            sut.Load(() => { count++; return(true); }, roles, permission, instance);
            Assert.AreEqual(1, count);
        }