public void DeleteEntriesForResource_RetrieveAllEntries() { AclManagerBase manager = MockAclManager(); Assert.IsTrue(manager.StoreEntry("Res", "Action", "U.User", Value.Grant), "StoreEntry should return true"); Assert.IsTrue(manager.StoreEntry("Res", "Action", "G.Group", Value.Deny), "StoreEntry should return true"); Assert.IsTrue(manager.StoreEntry("Res2", "Action2", "G.Group2", Value.Grant), "StoreEntry should return true"); Assert.IsTrue(manager.StoreEntry("Res2", "Action3", "U.User", Value.Deny), "StoreEntry should return true"); Assert.AreEqual(4, manager.TotalEntries, "Wrong entry count"); Assert.IsFalse(manager.DeleteEntriesForResource("Inexistent"), "DeleteEntriesForResource should return false"); Assert.AreEqual(4, manager.TotalEntries, "Wrong entry count"); Assert.IsTrue(manager.DeleteEntriesForResource("Res2"), "DeleteEntriesForResource should return true"); Assert.AreEqual(2, manager.TotalEntries, "Wrong entry count"); AclEntry[] allEntries = manager.RetrieveAllEntries(); Assert.AreEqual(2, allEntries.Length, "Wrong entry count"); Array.Sort(allEntries, delegate(AclEntry x, AclEntry y) { return(x.Subject.CompareTo(y.Subject)); }); AssertAclEntriesAreEqual(new AclEntry("Res", "Action", "G.Group", Value.Deny), allEntries[0]); AssertAclEntriesAreEqual(new AclEntry("Res", "Action", "U.User", Value.Grant), allEntries[1]); }
public void DeleteEntriesForResource_Resource_Empty() { AclManagerBase manager = MockAclManager(); var ex = Assert.Throws <ArgumentException>(() => manager.DeleteEntriesForResource("")); Assert.Equal("Resource cannot be empty.\r\nParameter name: resource", ex.Message); }
public void DeleteEntriesForResource_Resource_Null() { AclManagerBase manager = MockAclManager(); var ex = Assert.Throws <ArgumentNullException>(() => manager.DeleteEntriesForResource(null)); Assert.Equal("Value cannot be null.\r\nParameter name: resource", ex.Message); }
public void DeleteEntriesForResource_InvalidResource_ShouldThrowArgumentException(string r) { Assert.Throws <ArgumentException>(() => { AclManagerBase manager = MockAclManager(); manager.DeleteEntriesForResource(r); }); }
public void Event_AclChanged_DeleteEntriesForResource() { AclManagerBase manager = MockAclManager(); AclEntry entry = new AclEntry("Res", "Action", "U.User", Value.Grant); manager.StoreEntry(entry.Resource, entry.Action, entry.Subject, entry.Value); manager.StoreEntry("Res2", "Action", "G.Group", Value.Deny); bool invokedDelete = false; manager.AclChanged += delegate(object sender, AclChangedEventArgs e) { invokedDelete = true; Assert.AreEqual(1, e.Entries.Length, "Wrong entry count"); AssertAclEntriesAreEqual(entry, e.Entries[0]); Assert.AreEqual(Change.EntryDeleted, e.Change, "Wrong change"); }; manager.DeleteEntriesForResource(entry.Resource); Assert.IsTrue(invokedDelete, "Delete event not invoked"); }
public void DeleteEntriesForResource_InvalidResource(string r) { AclManagerBase manager = MockAclManager( ); manager.DeleteEntriesForResource(r); }