static void Main(string[] args) { //<Snippet2> GacInstalled myGacInstalled = new GacInstalled(); //</Snippet2> //<Snippet3> Object [] hostEvidence = { myGacInstalled }; Object [] assemblyEvidence = {}; Evidence myEvidence = new Evidence(hostEvidence, assemblyEvidence); GacIdentityPermission myPerm = (GacIdentityPermission)myGacInstalled.CreateIdentityPermission( myEvidence); Console.WriteLine(myPerm.ToXml().ToString()); //</Snippet3> //<Snippet4> GacInstalled myGacInstalledCopy = (GacInstalled)myGacInstalled.Copy(); bool result = myGacInstalled.Equals(myGacInstalledCopy); //</Snippet4> //<Snippet5> Console.WriteLine( "Hashcode = " + myGacInstalled.GetHashCode().ToString()); //</Snippet5> //<Snippet6> Console.WriteLine(myGacInstalled.ToString()); //</Snippet6> }
// Demonstrate the Check method, which determines whether the specified // evidence satisfies the membership condition. private bool CheckDemo() { Console.WriteLine( "************************************************************"); //<Snippet3> GacMembershipCondition Gac1 = new GacMembershipCondition(); GacInstalled myGac = new GacInstalled(); try { Object [] hostEvidence = { myGac }; Object [] assemblyEvidence = {}; Evidence myEvidence = new Evidence(hostEvidence, assemblyEvidence); bool retCode = Gac1.Check(myEvidence); Console.WriteLine("Result of Check = " + retCode.ToString() + "\n"); } catch (Exception e) { Console.WriteLine("Check failed : " + Gac1.ToString() + e); return(false); } //</Snippet3> return(true); }
public void GacInstalled_GetRequiredSize() { GacInstalled g = new GacInstalled(); Assert.AreEqual(1, GetRequiredSize(g, true), "GetRequiredSize-true"); Assert.AreEqual(1, GetRequiredSize(g, false), "GetRequiredSize-false"); }
public void Copy() { GacInstalled gac = new GacInstalled(); GacInstalled copy = (GacInstalled)gac.Copy(); Assert.AreEqual(gac, copy, "Equals"); Assert.IsFalse(Object.ReferenceEquals(gac, copy), "ReferenceEquals"); }
public static void GacInstalledCallMethods() { GacInstalled gi = new GacInstalled(); object obj = gi.Copy(); IPermission ip = gi.CreateIdentityPermission(new Evidence()); bool check = gi.Equals(new object()); int hash = gi.GetHashCode(); string str = gi.ToString(); }
public void GacInstalled_InitFromBuffer_OutOfRange() { char [] buffer = new char [1] { '\t' }; GacInstalled g = new GacInstalled(); Assert.AreEqual(4, InitFromBuffer(g, buffer, 4), "InitFromBuffer"); }
public void GacInstalled_OutputToBuffer_OutOfRange() { char[] buffer = new char [1] { '\t' }; GacInstalled g = new GacInstalled(); OutputToBuffer(g, buffer, 1, false); }
public void GacInstalled_InitFromBuffer_BadData() { char [] buffer = new char [1] { '\r' }; GacInstalled g = new GacInstalled(); Assert.AreEqual(0, InitFromBuffer(g, buffer, 0), "InitFromBuffer"); }
public void Equals() { GacInstalled gac = new GacInstalled(); Assert.IsFalse(gac.Equals(null), "Equals(null)"); GacInstalled g2 = new GacInstalled(); Assert.IsTrue(gac.Equals(g2), "Equals(g2)"); Assert.IsTrue(g2.Equals(gac), "Equals(gac)"); }
public void CreateIdentityPermission() { GacInstalled gac = new GacInstalled(); IPermission p = gac.CreateIdentityPermission(null); Assert.IsTrue((p is GacIdentityPermission), "GacIdentityPermission"); Assert.IsNotNull(p, "CreateIdentityPermission(null)"); p = gac.CreateIdentityPermission(new Evidence()); Assert.IsNotNull(p, "CreateIdentityPermission(Evidence)"); }
public void GacInstalled_OutputToBuffer() { char[] buffer = new char [2]; GacInstalled g = new GacInstalled(); Assert.AreEqual(1, OutputToBuffer(g, buffer, 0, false), "OutputToBuffer-false"); Assert.AreEqual('\t', buffer [0], "Buffer-false"); Assert.AreEqual(2, OutputToBuffer(g, buffer, 1, true), "OutputToBuffer-true"); Assert.AreEqual('\t', buffer [1], "Buffer-true"); }
public void GacInstalled_InitFromBuffer() { char[] buffer = new char [2] { '\t', '\t' }; GacInstalled g = new GacInstalled(); Assert.AreEqual(0, InitFromBuffer(g, buffer, 0), "InitFromBuffer-1"); Assert.AreEqual(1, InitFromBuffer(g, buffer, 1), "InitFromBuffer-2"); }
public void Check() { GacMembershipCondition gac = new GacMembershipCondition(); Evidence e = null; Assert.IsFalse(gac.Check(e), "Check (null)"); e = new Evidence(); Assert.IsFalse(gac.Check(e), "Check (empty)"); e.AddHost(new Zone(SecurityZone.MyComputer)); Assert.IsFalse(gac.Check(e), "Check (zone)"); GacInstalled g = new GacInstalled(); e.AddAssembly(g); Assert.IsFalse(gac.Check(e), "Check (gac-assembly)"); e.AddHost(g); Assert.IsTrue(gac.Check(e), "Check (gac-host)"); }
public void ToString_() { GacInstalled gac = new GacInstalled(); Assert.IsTrue(gac.ToString().StartsWith("<System.Security.Policy.GacInstalled version=\"1\"/>")); }
public void GetHashCode_() { GacInstalled gac = new GacInstalled(); Assert.AreEqual(0, gac.GetHashCode()); }
public void Constructor() { GacInstalled gac = new GacInstalled(); Assert.IsNotNull(gac); }
public void GacInstalled_OutputToBuffer_Null() { GacInstalled g = new GacInstalled(); OutputToBuffer(g, null, 0, false); }
public void GacInstalled_InitFromBuffer_Null() { GacInstalled g = new GacInstalled(); Assert.AreEqual(0, InitFromBuffer(g, null, 0), "InitFromBuffer"); }