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); }
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); }
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); }