public void EqualsWithChildren()
        {
            PolicyStatement ps = new PolicyStatement(new NamedPermissionSet(ps_Name));

            MyCodeGroup cgChild = new MyCodeGroup(new ApplicationDirectoryMembershipCondition(), ps);

            cgChild.Name        = "ChildName";
            cgChild.Description = "Child Descripiton";

            MyCodeGroup cg = new MyCodeGroup(new AllMembershipCondition(), ps);

            cg.Name        = "SomeName";
            cg.Description = "Some Description";
            cg.AddChild(cgChild);

            MyCodeGroup cg2 = new MyCodeGroup(cg.MembershipCondition, cg.PolicyStatement);

            cg2.Name        = cg.Name;
            cg2.Description = cg.Description;

            Assert.IsTrue(cg.Equals(cg2), "Should be equal when Children are ignored");
            Assert.IsTrue(!cg.Equals(cg2, true), "Should not be equal when Child count is different");

            cg2.AddChild(cgChild);
            Assert.IsTrue(cg2.Equals(cg, true), "Should be equal when children are equal");
        }
Exemplo n.º 2
0
		public void ToFromXmlRoundtrip () 
		{
			PolicyStatement ps = new PolicyStatement (new NamedPermissionSet (ps_Name));
			MyCodeGroup cg = new MyCodeGroup (new AllMembershipCondition (), ps);
			cg.Name = "SomeName";
			cg.Description = "Some Description";
			Assert.IsTrue (cg.Equals (cg), "Equals (itself)");
			SecurityElement se = cg.ToXml ();

			MyCodeGroup cg2 = new MyCodeGroup (new AllMembershipCondition(), ps);
			cg2.Name = "SomeOtherName";
			cg2.Description = "Some Other Description";
			Assert.IsTrue (!cg.Equals (cg2), "Equals (another)");

			cg2.FromXml (se);
			Assert.IsTrue (cg.Equals (cg2), "Equals (FromXml)");
		}
Exemplo n.º 3
0
		public void Equals ()
		{
			PolicyStatement ps = new PolicyStatement (new NamedPermissionSet (ps_Name));
			MyCodeGroup cg = new MyCodeGroup (new AllMembershipCondition (), ps);
			cg.Name = "SomeName";
			cg.Description = "Some Description";
			Assert.IsTrue (cg.Equals (cg), "Equals (itself)");
			Assert.IsTrue (!cg.Equals ("Not Equal to this"), "Equals (string)");

			MyCodeGroup cg2 = new MyCodeGroup(new AllMembershipCondition(), ps);
			cg2.Name = "SomeOtherName";
			cg2.Description = "Some Other Description";
			Assert.IsTrue (!cg.Equals (cg2), "Equals (another)");

			cg2 = new MyCodeGroup (new ApplicationDirectoryMembershipCondition(), ps);
			cg2.Name = cg.Name;
			cg2.Description = cg.Description;
			Assert.IsTrue (!cg.Equals (cg2), "Equals (different Membership Condition)");
		}
Exemplo n.º 4
0
		public void ToFromXmlRoundtrip_WithChildren_Second () 
		{
			PolicyStatement ps = new PolicyStatement (new NamedPermissionSet (ps_Name));

			// only the child is MySecondCodeGroup
			MySecondCodeGroup cgChild = new MySecondCodeGroup (new ApplicationDirectoryMembershipCondition (), ps);
			cgChild.Name = "ChildName";
			cgChild.Description = "Child Descripiton";

			MyCodeGroup cg = new MyCodeGroup (new AllMembershipCondition (), ps);
			cg.Name = "SomeName";
			cg.Description = "Some Description";
			cg.AddChild (cgChild);
			Assert.IsTrue (cg.Equals (cg), "Equals (itself)");
			SecurityElement se = cg.ToXml ();

			MyCodeGroup cg2 = (MyCodeGroup) cg.Copy ();
			cg2.FromXml (se);
			Assert.IsTrue (cg.Equals (cg2, true), "Equals (FromXml)");
		}
Exemplo n.º 5
0
		public void ToFromXmlRoundtrip_WithChildren () 
		{
			PolicyStatement ps = new PolicyStatement (new NamedPermissionSet (ps_Name));

			MyCodeGroup cgChild = new MyCodeGroup (new ApplicationDirectoryMembershipCondition (), ps);
			cgChild.Name = "ChildName";
			cgChild.Description = "Child Descripiton";

			MyCodeGroup cg = new MyCodeGroup (new AllMembershipCondition (), ps);
			cg.Name = "SomeName";
			cg.Description = "Some Description";
			cg.AddChild (cgChild);
			cg.AddChild (cgChild);
			Assert.IsTrue (cg.Equals (cg), "Equals (itself)");
			SecurityElement se = cg.ToXml ();

			MyCodeGroup cg2 = (MyCodeGroup) cg.Copy ();
			cg2.FromXml (se);
			// MissingMethodException down here (stangely not up here ?!? delayed ?)
			Assert.IsTrue (cg.Equals (cg2, true), "Equals (FromXml)");
		}
Exemplo n.º 6
0
		public void EqualsWithChildren ()
		{
			PolicyStatement ps = new PolicyStatement (new NamedPermissionSet (ps_Name));
			
			MyCodeGroup cgChild = new MyCodeGroup(new ApplicationDirectoryMembershipCondition(), ps);
			cgChild.Name = "ChildName";
			cgChild.Description = "Child Descripiton";

			MyCodeGroup cg = new MyCodeGroup (new AllMembershipCondition (), ps);
			cg.Name = "SomeName";
			cg.Description = "Some Description";
			cg.AddChild (cgChild);

			MyCodeGroup cg2 = new MyCodeGroup (cg.MembershipCondition, cg.PolicyStatement);
			cg2.Name = cg.Name;
			cg2.Description = cg.Description;

			Assert.IsTrue (cg.Equals (cg2), "Should be equal when Children are ignored");
			Assert.IsTrue (!cg.Equals(cg2, true), "Should not be equal when Child count is different");

			cg2.AddChild(cgChild);
			Assert.IsTrue (cg2.Equals(cg, true), "Should be equal when children are equal");
		}