private void checkConstruction( NamingAuthority auth, DerObjectIdentifier namingAuthorityID, string namingAuthorityURL, DirectoryString namingAuthorityText) { checkValues(auth, namingAuthorityID, namingAuthorityURL, namingAuthorityText); auth = NamingAuthority.GetInstance(auth); checkValues(auth, namingAuthorityID, namingAuthorityURL, namingAuthorityText); Asn1InputStream aIn = new Asn1InputStream(auth.ToAsn1Object().GetEncoded()); Asn1Sequence seq = (Asn1Sequence)aIn.ReadObject(); auth = NamingAuthority.GetInstance(seq); checkValues(auth, namingAuthorityID, namingAuthorityURL, namingAuthorityText); }
public override void PerformTest() { DerObjectIdentifier namingAuthorityID = new DerObjectIdentifier("1.2.3"); string namingAuthorityURL = "url"; DirectoryString namingAuthorityText = new DirectoryString("text"); NamingAuthority auth = new NamingAuthority(namingAuthorityID, namingAuthorityURL, namingAuthorityText); checkConstruction(auth, namingAuthorityID, namingAuthorityURL, namingAuthorityText); auth = new NamingAuthority(null, namingAuthorityURL, namingAuthorityText); checkConstruction(auth, null, namingAuthorityURL, namingAuthorityText); auth = new NamingAuthority(namingAuthorityID, null, namingAuthorityText); checkConstruction(auth, namingAuthorityID, null, namingAuthorityText); auth = new NamingAuthority(namingAuthorityID, namingAuthorityURL, null); checkConstruction(auth, namingAuthorityID, namingAuthorityURL, null); auth = NamingAuthority.GetInstance(null); if (auth != null) { Fail("null GetInstance() failed."); } try { NamingAuthority.GetInstance(new Object()); Fail("GetInstance() failed to detect bad object."); } catch (ArgumentException) { // expected } }