コード例 #1
0
        public void DeleteEntry_Subject_Empty()
        {
            AclManagerBase manager = MockAclManager();
            var            ex      = Assert.Throws <ArgumentException>(() => manager.DeleteEntry("Res", "Action", ""));

            Assert.Equal("Subject cannot be empty.\r\nParameter name: subject", ex.Message);
        }
コード例 #2
0
        public void DeleteEntry_Subject_Null()
        {
            AclManagerBase manager = MockAclManager();
            var            ex      = Assert.Throws <ArgumentNullException>(() => manager.DeleteEntry("Res", "Action", null));

            Assert.Equal("Value cannot be null.\r\nParameter name: subject", ex.Message);
        }
コード例 #3
0
        public void DeleteEntry_Resource_Empty()
        {
            AclManagerBase manager = MockAclManager();
            var            ex      = Assert.Throws <ArgumentException>(() => manager.DeleteEntry("", "Action", "U.User"));

            Assert.Equal("Resource cannot be empty.\r\nParameter name: resource", ex.Message);
        }
コード例 #4
0
        public void DeleteEntry_Resource_Null()
        {
            AclManagerBase manager = MockAclManager();
            var            ex      = Assert.Throws <ArgumentNullException>(() => manager.DeleteEntry(null, "Action", "U.User"));

            Assert.Equal("Value cannot be null.\r\nParameter name: resource", ex.Message);
        }
コード例 #5
0
 public void DeleteEntry_InvalidSubject_ShouldThrowArgumentException(string s)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         AclManagerBase manager = MockAclManager();
         manager.DeleteEntry("Res", "Action", s);
     });
 }
コード例 #6
0
 public void DeleteEntry_InvalidAction_ShouldThrowArgumentException(string a)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         AclManagerBase manager = MockAclManager();
         manager.DeleteEntry("Res", a, "U.User");
     });
 }
コード例 #7
0
 public void DeleteEntry_InvalidResource_ShouldThrowArgumentException(string r)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         AclManagerBase manager = MockAclManager();
         manager.DeleteEntry(r, "Action", "U.User");
     });
 }
コード例 #8
0
        public void DeleteEntry_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.AreEqual(2, manager.TotalEntries, "Wrong entry count");

            Assert.IsFalse(manager.DeleteEntry("Res1", "Action", "G.Group"), "DeleteEntry should return false");
            Assert.IsFalse(manager.DeleteEntry("Res", "Action1", "G.Group"), "DeleteEntry should return false");
            Assert.IsFalse(manager.DeleteEntry("Res", "Action", "G.Group1"), "DeleteEntry should return false");

            Assert.AreEqual(2, manager.TotalEntries, "Wrong entry count");

            Assert.IsTrue(manager.DeleteEntry("Res", "Action", "G.Group"), "DeleteEntry should return true");

            Assert.AreEqual(1, manager.TotalEntries, "Wrong entry count");

            AclEntry[] allEntries = manager.RetrieveAllEntries();
            Assert.AreEqual(1, allEntries.Length, "Wrong entry count");

            AssertAclEntriesAreEqual(new AclEntry("Res", "Action", "U.User", Value.Grant), allEntries[0]);
        }
コード例 #9
0
        public void Event_AclChanged_DeleteEntry()
        {
            AclManagerBase manager = MockAclManager();

            AclEntry entry = new AclEntry("Res", "Action", "U.User", Value.Grant);

            manager.StoreEntry(entry.Resource, entry.Action, entry.Subject, entry.Value);

            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.DeleteEntry(entry.Resource, entry.Action, entry.Subject);

            Assert.IsTrue(invokedDelete, "Delete event not invoked");
        }
コード例 #10
0
        public void DeleteEntry_InvalidSubject(string s)
        {
            AclManagerBase manager = MockAclManager( );

            manager.DeleteEntry("Res", "Action", s);
        }
コード例 #11
0
        public void DeleteEntry_InvalidAction(string a)
        {
            AclManagerBase manager = MockAclManager( );

            manager.DeleteEntry("Res", a, "U.User");
        }
コード例 #12
0
        public void DeleteEntry_InvalidResource(string r)
        {
            AclManagerBase manager = MockAclManager( );

            manager.DeleteEntry(r, "Action", "U.User");
        }