Esempio n. 1
0
        public void GetPrivilege()
        {
            Assert.IsNull(m_profile.GetPrivileges().FirstOrDefault());
            Assert.IsNull(m_profile2.GetPrivileges().FirstOrDefault());

            List <Privilege> privileges = new List <Privilege>();

            Privilege priv = new Privilege("CREATE", "employee");

            m_profile.AddPrivilege(priv);
            privileges.Add(priv);

            priv = new Privilege("DROP", "project");

            m_profile.AddPrivilege(priv);
            privileges.Add(priv);

            Assert.AreEqual(privileges.Count, m_profile.GetPrivileges().Count);

            for (int i = 0; i < privileges.Count; i++)
            {
                Privilege privilege  = privileges[i];
                Privilege privilege2 = m_profile.GetPrivilege(privilege.GetPrivilege(), privilege.GetTable());
                Assert.AreEqual(privilege.GetPrivilege(), privilege2.GetPrivilege());
                Assert.AreEqual(privilege.GetTable(), privilege2.GetTable());
            }

            privileges.Clear();
            priv = new Privilege("UPDATE", "location");

            m_profile2.AddPrivilege(priv);
            privileges.Add(priv);

            Assert.AreEqual(privileges.Count, m_profile2.GetPrivileges().Count);

            for (int i = 0; i < privileges.Count; i++)
            {
                Privilege privilege  = privileges[i];
                Privilege privilege2 = m_profile2.GetPrivilege(privilege.GetPrivilege(), privilege.GetTable());
                Assert.AreEqual(privilege.GetPrivilege(), privilege2.GetPrivilege());
                Assert.AreEqual(privilege.GetTable(), privilege2.GetTable());
            }
        }
Esempio n. 2
0
 public void TestGetTable()
 {
     Assert.AreEqual("table1", m_privilege.GetTable());
     Assert.AreEqual("table2", m_privilege2.GetTable());
 }