public void Unrestricted() { OleDbPermissionAttribute a = new OleDbPermissionAttribute(SecurityAction.Assert); a.Unrestricted = true; OleDbPermission odp = (OleDbPermission)a.CreatePermission(); Assert.IsTrue(odp.IsUnrestricted(), "IsUnrestricted"); Assert.IsFalse(a.AllowBlankPassword, "AllowBlankPassword"); Assert.AreEqual(String.Empty, a.ConnectionString, "ConnectionString"); Assert.AreEqual(KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior"); Assert.AreEqual(String.Empty, a.KeyRestrictions, "KeyRestrictions"); a.Unrestricted = false; odp = (OleDbPermission)a.CreatePermission(); Assert.IsFalse(odp.IsUnrestricted(), "!IsUnrestricted"); }
private void Check(string msg, OleDbPermission perm, bool blank, bool unrestricted, int count) { Assert.AreEqual(blank, perm.AllowBlankPassword, msg + ".AllowBlankPassword"); Assert.AreEqual(unrestricted, perm.IsUnrestricted(), msg + ".IsUnrestricted"); if (count == 0) { Assert.IsNull(perm.ToXml().Children, msg + ".Count != 0"); } else { Assert.AreEqual(count, perm.ToXml().Children.Count, msg + ".Count"); } Assert.AreEqual(String.Empty, perm.Provider, "Provider"); }
}// CreateDataTable protected override void PutValuesinPage() { // Put in the text for the radio buttons m_radUnrestricted.Text = CResourceStore.GetString("OleDbPermission:GrantUnrestrict"); m_radGrantFollowingPermission.Text = CResourceStore.GetString("OleDbPermission:GrantFollowing"); // Adjust some of the UI components on this page (and put in a checkbox) System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(COleDbPermControls)); this.m_chkAllowBlank = new System.Windows.Forms.CheckBox(); this.m_btnDeleteRow.Location = ((System.Drawing.Point)(resources.GetObject("m_btn.Location"))); this.m_chkAllowBlank.Location = ((System.Drawing.Point)(resources.GetObject("m_chkAllowBlank.Location"))); this.m_chkAllowBlank.Name = "m_chkAllowBlank"; this.m_chkAllowBlank.Size = ((System.Drawing.Size)(resources.GetObject("m_chkAllowBlank.Size"))); this.m_chkAllowBlank.TabIndex = ((int)(resources.GetObject("m_chkAllowBlank.TabIndex"))); this.m_chkAllowBlank.Text = resources.GetString("m_chkAllowBlank.Text"); this.m_dg.Size = ((System.Drawing.Size)(resources.GetObject("m_dg.Size"))); this.m_chkAllowBlank.Click += new EventHandler(onChange); m_ucOptions.Controls.Add(this.m_chkAllowBlank); OleDbPermission perm = (OleDbPermission)m_perm; CheckUnrestricted(perm); if (!perm.IsUnrestricted()) { String[] sProviders = perm.Provider.Split(new char[] { ';' }); for (int i = 0; i < sProviders.Length; i++) { if (sProviders[i].Length > 0) { DataRow newRow = m_dt.NewRow(); newRow["Provider"] = sProviders[i]; m_dt.Rows.Add(newRow); } } m_chkAllowBlank.Checked = perm.AllowBlankPassword; } // We want at least 1 rows so it looks pretty while (m_dt.Rows.Count < 1) { AddEmptyRow(m_dt); } }// PutValuesinPage
public void Default() { OleDbPermissionAttribute a = new OleDbPermissionAttribute(SecurityAction.Assert); Assert.AreEqual(a.ToString(), a.TypeId.ToString(), "TypeId"); Assert.IsFalse(a.Unrestricted, "Unrestricted"); Assert.IsFalse(a.AllowBlankPassword, "AllowBlankPassword"); Assert.AreEqual(String.Empty, a.ConnectionString, "ConnectionString"); Assert.AreEqual(KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior"); Assert.AreEqual(String.Empty, a.KeyRestrictions, "KeyRestrictions"); Assert.AreEqual(String.Empty, a.Provider, "Provider"); Assert.IsFalse(a.ShouldSerializeConnectionString(), "ShouldSerializeConnectionString"); Assert.IsFalse(a.ShouldSerializeKeyRestrictions(), "ShouldSerializeConnectionString"); OleDbPermission odp = (OleDbPermission)a.CreatePermission(); Assert.IsFalse(odp.IsUnrestricted(), "IsUnrestricted"); }