Esempio n. 1
0
        public override void PerformTest()
        {
            DerObjectIdentifier  statementId = new DerObjectIdentifier("1.1");
            SemanticsInformation mv          = new SemanticsInformation(statementId);

            CheckConstruction(mv, statementId, null);

            GeneralName[] names = new GeneralName[2];

            names[0] = new GeneralName(GeneralName.Rfc822Name, "*****@*****.**");
            names[1] = new GeneralName(new X509Name("cn=test"));

            mv = new SemanticsInformation(statementId, names);

            CheckConstruction(mv, statementId, names);

            mv = new SemanticsInformation(names);

            CheckConstruction(mv, null, names);

            mv = SemanticsInformation.GetInstance(null);

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

            try
            {
                SemanticsInformation.GetInstance(new object());

                Fail("GetInstance() failed to detect bad object.");
            }
            catch (ArgumentException)
            {
                // expected
            }

            try
            {
                new SemanticsInformation(DerSequence.Empty);

                Fail("constructor failed to detect empty sequence.");
            }
            catch (ArgumentException)
            {
                // expected
            }
        }
Esempio n. 2
0
        private void CheckConstruction(
            SemanticsInformation mv,
            DerObjectIdentifier semanticsIdentifier,
            GeneralName[]                       names)
        {
            CheckStatement(mv, semanticsIdentifier, names);

            mv = SemanticsInformation.GetInstance(mv);

            CheckStatement(mv, semanticsIdentifier, names);

            Asn1Sequence seq = (Asn1Sequence)Asn1Object.FromByteArray(mv.ToAsn1Object().GetEncoded());

            mv = SemanticsInformation.GetInstance(seq);

            CheckStatement(mv, semanticsIdentifier, names);
        }