public Test(string dn, string rdn, LDIFDistinguishedName parent, string name, string nameType, int depth, LDIFDistinguishedName[] hierarchy, Type exceptionType = null) { DN = dn; ExpectedRDN = rdn; ExpectedParent = parent; ExpectedName = name; ExpectedNameType = nameType; ExpectedDepth = depth; ExpectedParentHierarchy = hierarchy; ExpectedException = exceptionType; }
static void Main(string[] args) { LDIFDistinguishedName dn1 = "cn=foo,cn=bar"; LDIFDistinguishedName dn2 = dn1; foreach (Test t in Tests) { Console.WriteLine("Testing [{0}]", t.DN); try { LDIFDistinguishedName dn = new LDIFDistinguishedName(t.DN); if (dn.RDN.CompareTo(t.ExpectedRDN) != 0) { Console.WriteLine("Failed: DN [{0}] RDN {1} expected {2}", t.DN, dn.RDN, t.ExpectedRDN); } if (dn.Parent.CompareTo(t.ExpectedParent) != 0) { Console.WriteLine("Failed: DN [{0}] Parent {1} expected {2}", t.DN, dn.Parent, t.ExpectedParent); } if (dn.Name.CompareTo(t.ExpectedName) != 0) { Console.WriteLine("Failed: DN [{0}] Name {1} expected {2}", t.DN, dn.Name, t.ExpectedName); } // Should ignore case on the compare if (dn.NameType.CompareTo(t.ExpectedNameType) != 0) { Console.WriteLine("Failed: DN [{0}] NameType {1} expected {2}", t.DN, dn.NameType, t.ExpectedNameType); } if (dn.Depth != t.ExpectedDepth) { Console.WriteLine("Failed: DN [{0}] Depth {1} expected {2}", t.DN, dn.Depth, t.ExpectedDepth); } if (!t.ExpectedParentHierarchy.IsEqualTo <LDIFDistinguishedName>(dn.ParentHierarchy, new LDIFDistinguishedName.EqualityComparator())) { Console.WriteLine(dn.ParentHierarchy.Join(";")); Console.WriteLine(t.ExpectedParentHierarchy.Join(";")); } } catch (System.Exception e) { if (t.ExpectedException == null || e.GetType() != t.ExpectedException) { Console.WriteLine("Failed: DN [{0}] Caught exception {1} when expecting {2}", t.DN, e.GetType(), t.ExpectedException == null ? "no exception" : t.ExpectedException.ToString()); } } } }