Example #1
0
        public override void PerformTest()
        {
            DerGeneralizedTime    dateOfBirth = new DerGeneralizedTime("20070315173729Z");
            DeclarationOfMajority decl        = new DeclarationOfMajority(dateOfBirth);

            checkConstruction(decl, DeclarationOfMajority.Choice.DateOfBirth, dateOfBirth, -1);

            decl = new DeclarationOfMajority(6);

            checkConstruction(decl, DeclarationOfMajority.Choice.NotYoungerThan, null, 6);

            decl = DeclarationOfMajority.GetInstance(null);

            if (decl != null)
            {
                Fail("null GetInstance() failed.");
            }

            try
            {
                DeclarationOfMajority.GetInstance(new Object());

                Fail("GetInstance() failed to detect bad object.");
            }
            catch (ArgumentException)
            {
                // expected
            }
        }
Example #2
0
 private void checkValues(
     DeclarationOfMajority decl,
     DeclarationOfMajority.Choice type,
     DerGeneralizedTime dateOfBirth,
     int notYoungerThan)
 {
     checkMandatoryField("type", (int)type, (int)decl.Type);
     checkOptionalField("dateOfBirth", dateOfBirth, decl.DateOfBirth);
     if (notYoungerThan != -1 && notYoungerThan != decl.NotYoungerThan)
     {
         Fail("notYoungerThan mismatch");
     }
 }
Example #3
0
        private void CheckConstruction(
            DeclarationOfMajority decl,
            DeclarationOfMajority.Choice type,
            DerGeneralizedTime dateOfBirth,
            int notYoungerThan)
        {
            CheckValues(decl, type, dateOfBirth, notYoungerThan);

            decl = DeclarationOfMajority.GetInstance(decl);

            CheckValues(decl, type, dateOfBirth, notYoungerThan);

            decl = DeclarationOfMajority.GetInstance(Asn1Object.FromByteArray(decl.GetEncoded()));

            CheckValues(decl, type, dateOfBirth, notYoungerThan);
        }
Example #4
0
        private void checkConstruction(
            DeclarationOfMajority decl,
            DeclarationOfMajority.Choice type,
            DerGeneralizedTime dateOfBirth,
            int notYoungerThan)
        {
            checkValues(decl, type, dateOfBirth, notYoungerThan);

            decl = DeclarationOfMajority.GetInstance(decl);

            checkValues(decl, type, dateOfBirth, notYoungerThan);

            Asn1InputStream aIn = new Asn1InputStream(decl.ToAsn1Object().GetEncoded());

            DerTaggedObject info = (DerTaggedObject)aIn.ReadObject();

            decl = DeclarationOfMajority.GetInstance(info);

            checkValues(decl, type, dateOfBirth, notYoungerThan);
        }