public MFTestResults AddThenVerifyUpdateNotificationMessage()
        {
            MFTestResults testResult = MFTestResults.Pass;

            try
            {
                Log.Comment("Add Certificates then Verify the events received.");
                CertificateStore.AddCACertificate("cert1", new X509Certificate(CertificatesAndCAs.caCert));
                CertificateStore.AddCACertificate("cert2", new X509Certificate(CertificatesAndCAs.newCert));

                Log.Comment("Sign up to get the notification messages");
                CertificateStore.CertificateNotificationMessage message = new CertificateStore.CertificateNotificationMessage(CertificateMessage);
                CertificateStore.OnCACertificateChange += message;

                Log.Comment("Updating cert1");
                CertificateStore.UpdateCACertificate("cert1", new X509Certificate(CertificatesAndCAs.newCert));
                Thread.Sleep(100);
                if (notifiedCertName != "cert1")
                {
                    Log.Comment("invalid certificate notification message");
                    testResult = MFTestResults.Fail;
                }

                if (notifiedType != CertificateStore.CertificateNotificationType.Updated)
                {
                    Log.Comment("invalid certificate notification type");
                    testResult = MFTestResults.Fail;
                }

                Log.Comment("Updating cert2");
                CertificateStore.UpdateCACertificate("cert2", new X509Certificate(CertificatesAndCAs.caCert));

                Thread.Sleep(100);
                if (notifiedCertName != "cert2")
                {
                    Log.Comment("invalid certificate notification message");
                    testResult = MFTestResults.Fail;
                }

                if (notifiedType != CertificateStore.CertificateNotificationType.Updated)
                {
                    Log.Comment("invalid certificate notification type");
                    testResult = MFTestResults.Fail;
                }


                if (numNotificationCalls != 2)
                {
                    Log.Comment("the CertificatNotification message should be called twice but is called: " + numNotificationCalls);
                    testResult = MFTestResults.Fail;
                }
                numNotificationCalls = 0;

                CertificateStore.OnCACertificateChange -= message;
                Log.Comment("clean up the cert that was added.");
                CertificateStore.RemoveCACertificate("cert1");
                CertificateStore.RemoveCACertificate("cert2");
            }
            catch
            {
                testResult = MFTestResults.Fail;
            }
            finally
            {
                CertificateStore.ClearAllCertificates();
            }

            return(testResult);
        }
        public MFTestResults AddThenVerifyUpdateNotificationMessage()
        {
            MFTestResults testResult = MFTestResults.Pass;

            try
            {
                Log.Comment("Add Certificates then Verify the events received.");
                CertificateStore.AddCACertificate("cert1", new X509Certificate(CertificatesAndCAs.caCert));
                CertificateStore.AddCACertificate("cert2", new X509Certificate(CertificatesAndCAs.newCert));

                Log.Comment("Sign up to get the notification messages");
                CertificateStore.CertificateNotificationMessage message = new CertificateStore.CertificateNotificationMessage(CertificateMessage);
                CertificateStore.OnCACertificateChange += message;

                Log.Comment("Updating cert1");
                CertificateStore.UpdateCACertificate("cert1", new X509Certificate(CertificatesAndCAs.newCert));
                Thread.Sleep(100);
                if (notifiedCertName != "cert1")
                {
                    Log.Comment("invalid certificate notification message");
                    testResult = MFTestResults.Fail;
                }

                if (notifiedType != CertificateStore.CertificateNotificationType.Updated)
                {
                    Log.Comment("invalid certificate notification type");
                    testResult = MFTestResults.Fail;
                }

                Log.Comment("Updating cert2");
                CertificateStore.UpdateCACertificate("cert2", new X509Certificate(CertificatesAndCAs.caCert));

                Thread.Sleep(100);
                if (notifiedCertName != "cert2")
                {
                    Log.Comment("invalid certificate notification message");
                    testResult = MFTestResults.Fail;
                }

                if (notifiedType != CertificateStore.CertificateNotificationType.Updated)
                {
                    Log.Comment("invalid certificate notification type");
                    testResult = MFTestResults.Fail;
                }


                if (numNotificationCalls != 2)
                {
                    Log.Comment("the CertificatNotification message should be called twice but is called: " + numNotificationCalls);
                    testResult = MFTestResults.Fail;
                }
                numNotificationCalls = 0;

                CertificateStore.OnCACertificateChange -= message;
                Log.Comment("clean up the cert that was added.");
                CertificateStore.RemoveCACertificate("cert1");
                CertificateStore.RemoveCACertificate("cert2");
            }
            catch
            {
                testResult = MFTestResults.Fail;
            }
            finally
            {
                CertificateStore.ClearAllCertificates();
            }

            return testResult;
        }