Exemple #1
0
        public void CanReadTestVectorPayments()
        {
            var tests = new[]
            {
                "data/payreq1_sha256_omitteddefault.paymentrequest",
                "data/payreq1_sha256.paymentrequest",
                "data/payreq2_sha256_omitteddefault.paymentrequest",
                "data/payreq2_sha256.paymentrequest",
                "data/payreq1_sha1_omitteddefault.paymentrequest",
                "data/payreq1_sha1.paymentrequest",
                "data/payreq2_sha1_omitteddefault.paymentrequest",
                "data/payreq2_sha1.paymentrequest",
            };

            foreach (var provider in new ICertificateServiceProvider[]
            {
#if WIN
                new WindowsCertificateServiceProvider(X509VerificationFlags.IgnoreNotTimeValid |
                                                      X509VerificationFlags.AllowUnknownCertificateAuthority |
                                                      X509VerificationFlags.IgnoreRootRevocationUnknown |
                                                      X509VerificationFlags.IgnoreCertificateAuthorityRevocationUnknown |
                                                      X509VerificationFlags.IgnoreEndRevocationUnknown)
#endif
            })
            {
                PaymentRequest.DefaultCertificateServiceProvider = provider;
                foreach (var test in tests)
                {
                    var bytes   = File.ReadAllBytes(test);
                    var request = PaymentRequest.Load(bytes);
                    AssertEx.Equal(request.ToBytes(), bytes);

                    Assert.True(request.VerifySignature());
                    request = PaymentRequest.Load(PaymentRequest.Load(bytes).ToBytes());
                    Assert.True(request.VerifySignature());
                    Assert.True(request.VerifyChain());
                }
            }
        }
Exemple #2
0
        public void util_MedianFilter()
        {
            MedianFilterInt32 filter = new MedianFilterInt32(5, 15);

            AssertEx.Equal(filter.Median, 15);

            filter.Input(20);             // [15 20]
            AssertEx.Equal(filter.Median, 17);

            filter.Input(30);             // [15 20 30]
            AssertEx.Equal(filter.Median, 20);

            filter.Input(3);             // [3 15 20 30]
            AssertEx.Equal(filter.Median, 17);

            filter.Input(7);             // [3 7 15 20 30]
            AssertEx.Equal(filter.Median, 15);

            filter.Input(18);             // [3 7 18 20 30]
            AssertEx.Equal(filter.Median, 18);

            filter.Input(0);             // [0 3 7 18 30]
            AssertEx.Equal(filter.Median, 7);
        }