public void Deserialize_CompleteResultXml_ReturnsCompleteResultObject()
        {
            ResultParser resultParser = new ResultParser();
            CompleteResult result = resultParser.Deserialize<CompleteResult>(Factory.CompleteResult);

            Assert.IsNotNull(result);
        }
        public void Deserialize_InitializeResultXml_ReturnsInitializeResultObject()
        {
            ResultParser resultParser = new ResultParser();
            InitializeResult result = resultParser.Deserialize<InitializeResult>(Factory.InitializeResult);

            Assert.IsNotNull(result);
        }
        public void Deserialize_CompleteIsSuccessful_ReturnsNonEmptyPaymentMethod()
        {
            ResultParser resultParser = new ResultParser();
            CompleteResult result = resultParser.Deserialize<CompleteResult>(Factory.CompleteResult);

            Assert.IsNotNullOrEmpty(result.PaymentMethod);
        }
        public void Deserialize_InitializeIsUnsuccessful_ReturnsSuccessFalse()
        {
            ResultParser resultParser = new ResultParser();
            CompleteResult result = resultParser.Deserialize<CompleteResult>(Factory.InitializeResultError);

            Assert.IsFalse(result.Success);
        }
        public void Deserialize_InitializeIsSuccessful_ReturnsNonEmptyRedirectUrl()
        {
            ResultParser resultParser = new ResultParser();
            InitializeResult result = resultParser.Deserialize<InitializeResult>(Factory.InitializeResult);

            Assert.IsNotNullOrEmpty(result.RedirectUrl);
        }
        public void Deserialize_CompleteIsSuccessful_ReturnsSuccessTrue()
        {
            ResultParser resultParser = new ResultParser();
            CompleteResult result = resultParser.Deserialize<CompleteResult>(Factory.CompleteResult);

            Assert.IsNotNull(result.Status);
        }
        public void Deserialize_CompleteIsSuccessful_ReturnsNonEmptyTransactionNumber()
        {
            ResultParser resultParser = new ResultParser();
            CompleteResult result = resultParser.Deserialize<CompleteResult>(Factory.CompleteResult);

            Assert.IsNotNullOrEmpty(result.TransactionNumber);
        }
        public void Deserialize_InitializeIsSuccessful_ReturnsNonEmptyOrderRef()
        {
            ResultParser resultParser = new ResultParser();
            InitializeResult result = resultParser.Deserialize<InitializeResult>(Factory.InitializeResult);

            Assert.IsTrue(result.OrderRef != Guid.Empty);
        }
Exemple #9
0
        /// <summary>
        /// Initiates a transaction.
        /// </summary>
        /// <param name="settings">The initiate transaction request settings.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>The transaction result.</returns>
        public async Task <TransactionResult> InitiateTransactionAsync(
            InitiateTransactionSettings settings,
            CancellationToken cancellationToken = default)
        {
            var request = RequestBuilder.CreateAcquirerRequest(
                merchantId,
                settings);

            var response = await SendObjectAsXmlAsync(
                request,
                cancellationToken);

            return(ResultParser.ParseTransactionResult(response));
        }
Exemple #10
0
        /// <summary>
        /// Credit a transaction after a completed purchase.
        /// The credit functionality can behave differently based on the payment instrument and/or if the financial institution
        /// accepts credit instructions (not all do). Also note that some financial institutions don’t support partial credit
        /// before 24 hours have past. Please contact PayEx Support for more information.
        /// </summary>
        /// <param name="transactionNumber">The transactionNumber of the transaction you wish to credit.</param>
        /// <param name="amount">The amount you wish to credit.</param>
        /// <param name="orderID">
        /// Order Id that will be presented in PayEx report. This value have to be numeric if merchant have
        /// chosen to send orderId to the aquiring institution.
        /// </param>
        public async Task <CreditResult> Credit(int transactionNumber, decimal amount, string orderID)
        {
            // Validation
            if (transactionNumber <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(transactionNumber), "transactionNumber is required");
            }
            if (amount <= decimal.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(amount), "amount must be non-zero.");
            }

            // Null not allowed
            orderID = orderID ?? string.Empty;
            var convAmount       = amount.ToPayEx();
            var vatAmount        = 0;
            var additionalValues = string.Empty;

            // Build string for md5 including all fields except empty strings
            var hashInput = new StringBuilder();

            hashInput.Append(Account.AccountNumber);
            hashInput.Append(transactionNumber);
            hashInput.Append(convAmount);
            hashInput.Append(orderID);
            hashInput.Append(vatAmount);
            hashInput.Append(additionalValues);
            // Add encryption key at the end of string to be hashed
            hashInput.Append(Account.EncryptionKey);
            // Create a hash string from the parameters
            string hash;

            MD5Hash.Hash(hashInput.ToString(), out hash);

            // Invoke Initialize method on external PayEx PxOrder web service
            var payexOrder = GetPxOrderClient();
            var xmlReturn  = await payexOrder.Credit5Async(
                Account.AccountNumber,
                transactionNumber,
                convAmount,
                orderID,
                vatAmount,
                additionalValues,
                hash);

            // Parse the result and retrieve code-node to figure out if the service method was invoked successfully.
            var result = ResultParser.ParseCreditResult(xmlReturn);

            return(result);
        }
Exemple #11
0
        private void btnExtendedResult_Click(object sender, EventArgs e)
        {
            if (lastResults.Count < 1)
            {
                return;
            }
            var parsedResult = ResultParser.parseResult(lastResults[0]);

            using (var dlg = new ExtendedResultForm())
            {
                dlg.Result = parsedResult;
                dlg.ShowDialog(this);
            }
        }
Exemple #12
0
        private void saveToHistory(Result qr)
        {
            var tag = ResultParser.parseResult(qr).Type;

            int cat = BarcodeType.Text;

            switch (tag)
            {
            case ParsedResultType.URI:
                cat = BarcodeType.Link;
                break;

            case ParsedResultType.TEL:
                cat = BarcodeType.Contact;
                break;

            case ParsedResultType.PRODUCT:
                cat = BarcodeType.Barcode;
                break;

            case ParsedResultType.ISBN:
                cat = BarcodeType.Book;
                break;

            case ParsedResultType.ADDRESSBOOK:
                cat = BarcodeType.Namecard;
                break;

            case ParsedResultType.CALENDAR:
                cat = BarcodeType.Event;
                break;

            case ParsedResultType.WIFI:
                cat = BarcodeType.Network;
                break;

            case ParsedResultType.EMAIL_ADDRESS:
                cat = BarcodeType.Email;
                break;

            default:
                cat = BarcodeType.Text;
                break;
            }

            this.session.Execute(DbFactory.InsertCommand, cat, qr.Text, DateTime.Now);

            this.btnOpen.Visibility = cat == BarcodeType.Link ? Visibility.Visible : Visibility.Collapsed;
        }
Exemple #13
0
        private static void doTestResult(String contents,
                                         String goldenResult,
                                         ParsedResultType type,
                                         BarcodeFormat format)
        {
            ZXing.Result fakeResult = new ZXing.Result(contents, null, null, format);
            ParsedResult result     = ResultParser.parseResult(fakeResult);

            Assert.IsNotNull(result);
            Assert.AreEqual(type, result.Type);

            String displayResult = result.DisplayResult;

            Assert.AreEqual(goldenResult, displayResult);
        }
Exemple #14
0
        public void NUnitFaildInt()
        {
            string       rawResult = "[failed] Test NUnit v2.4.7.0/RedGreenPlayground/NUnitTests/IntFail\nMessage\n  Expected: 0\n  But was:  1\n\nStack Trace\n   at NUnit.Framework.Assert.That(Object actual, Constraint constraint, String message, Object[] args)\n   at NUnit.Framework.Assert.AreEqual(Int32 expected, Int32 actual, String message, Object[] args)\n   at NUnit.Framework.Assert.AreEqual(Int32 expected, Int32 actual)\n   at RedGreenPlayground.NUnitTests.IntFail() in C:\\Users\\jaargero.WRPWI\\Documents\\Visual Studio 2005\\Projects\\RedGreenPlayground\\RedGreenPlayground\\NUnitTests.cs:line 28\n\n";
            ResultParser parser    = new ResultParser();

            RedGreen.TestResult parsed = parser.ParseTest(rawResult);

            Assert.Equal(RedGreen.TestStatus.Failed, parsed.Status);
            Assert.Equal(string.Empty, parsed.Duration);
            Assert.Equal("0", parsed.Failure.Expected);
            Assert.Equal("1", parsed.Failure.Actual);
            Assert.Equal(0, parsed.Failure.ActualDiffersAt);
            Assert.Null(parsed.Failure.FailingStatement);
            Assert.Equal("RedGreenPlayground.NUnitTests.IntFail", parsed.Location);
        }
Exemple #15
0
        public void MbUnitFailedTestStringFail()
        {
            string       rawResult = "[failed] Test MbUnit v3.0.5.546/RedGreenPlayground/MbUnitTests/AlwaysFails\nExpected values to be equal.\n\nExpected Value : \"who\'s there\"\nActual Value   : \"who\'s where\"\n\n   at RedGreenPlayground.MbUnitTests.AlwaysFails() in C:\\Users\\jaargero.WRPWI\\Documents\\Visual Studio 2005\\Projects\\RedGreenPlayground\\RedGreenPlayground\\MbUnitTests.cs:line 21\n";
            ResultParser parser    = new ResultParser();

            RedGreen.TestResult parsed = parser.ParseTest(rawResult);

            Assert.Equal(RedGreen.TestStatus.Failed, parsed.Status);
            Assert.Equal(string.Empty, parsed.Duration);
            Assert.Equal("\"who\'s there\"", parsed.Failure.Expected);
            Assert.Equal("\"who\'s where\"", parsed.Failure.Actual);
            Assert.Equal(7, parsed.Failure.ActualDiffersAt);
            Assert.Null(parsed.Failure.FailingStatement);
            Assert.Equal("RedGreenPlayground.MbUnitTests.AlwaysFails", parsed.Location);
        }
        /// <summary>
        /// Given the string contents for the barcode, check that it matches our expectations
        /// </summary>
        private static void doTest(String contents,
                                   String ssid,
                                   String password,
                                   String type)
        {
            var fakeResult = new ZXing.Result(contents, null, null, BarcodeFormat.QR_CODE);
            var result     = ResultParser.parseResult(fakeResult);

            // Ensure it is a wifi code
            Assert.AreEqual(ParsedResultType.WIFI, result.Type);
            var wifiResult = (WifiParsedResult)result;

            Assert.AreEqual(ssid, wifiResult.Ssid);
            Assert.AreEqual(password, wifiResult.Password);
            Assert.AreEqual(type, wifiResult.NetworkEncryption);
        }
        private static void doTest(String contents,
                                   String email,
                                   String subject,
                                   String body)
        {
            ZXing.Result fakeResult = new ZXing.Result(contents, null, null, BarcodeFormat.QR_CODE);
            ParsedResult result     = ResultParser.parseResult(fakeResult);

            Assert.AreEqual(ParsedResultType.EMAIL_ADDRESS, result.Type);
            EmailAddressParsedResult emailResult = (EmailAddressParsedResult)result;

            Assert.AreEqual(email, emailResult.EmailAddress);
            Assert.AreEqual("mailto:" + email, emailResult.MailtoURI);
            Assert.AreEqual(subject, emailResult.Subject);
            Assert.AreEqual(body, emailResult.Body);
        }
Exemple #18
0
        private static void doTest(String contents,
                                   String[] numbers,
                                   String subject,
                                   String body,
                                   String[] vias)
        {
            ZXing.Result fakeResult = new ZXing.Result(contents, null, null, BarcodeFormat.QR_CODE);
            ParsedResult result     = ResultParser.parseResult(fakeResult);

            Assert.AreEqual(ParsedResultType.SMS, result.Type);
            SMSParsedResult smsResult = (SMSParsedResult)result;

            Assert.IsTrue(AddressBookParsedResultTestCase.AreEqual(numbers, smsResult.Numbers));
            Assert.AreEqual(subject, smsResult.Subject);
            Assert.AreEqual(body, smsResult.Body);
            Assert.IsTrue(AddressBookParsedResultTestCase.AreEqual(vias, smsResult.Vias));
        }
Exemple #19
0
        /// <summary>
        /// Creates a new agreement between the merchant and the client. Before any AutoPay transactions can take place the client
        /// has to complete a purchase with the agreement reference. The agreement will be set to verified when this is done.
        /// Documentation: http://www.payexpim.com/technical-reference/pxagreement/createagreement3/
        /// </summary>
        /// <param name="request">The parameters to the CreateAgreement request</param>
        public async Task <CreateAgreementResult> CreateAgreement(CreateAgreementRequest request)
        {
            // Validation
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request), "request is required");
            }

            var notifyUrl = string.Empty; // Deprecated, leave blank

            // Build string for md5 including all fields except empty strings and description field
            var hashInput = new StringBuilder();

            hashInput.Append(Account.AccountNumber);
            hashInput.Append(request.MerchantRef);
            hashInput.Append(request.Description);
            hashInput.Append(request.PurchaseOperation.ToPayEx());
            hashInput.Append(request.MaxAmount.ToPayEx());
            hashInput.Append(notifyUrl);
            hashInput.Append(request.StartDate.ToPayEx());
            hashInput.Append(request.StopDate.ToPayEx());
            // Add encryption key at the end of string to be hashed
            hashInput.Append(Account.EncryptionKey);
            // Create a hash string from the parameters
            string hash;

            MD5Hash.Hash(hashInput.ToString(), out hash);

            // Invoke Initialize method on external PayEx PxOrder web service
            var payexAgreement = GetPxAgreementClient();
            var xmlReturn      = await payexAgreement.CreateAgreement3Async(
                Account.AccountNumber,
                request.MerchantRef ?? "",
                request.Description ?? "",
                request.PurchaseOperation.ToPayEx(),
                request.MaxAmount.ToPayEx(),
                notifyUrl,
                request.StartDate.ToPayEx(),
                request.StopDate.ToPayEx(),
                hash);

            // Parse the result
            var result = ResultParser.ParseCreateAgreementResult(xmlReturn);

            return(result);
        }
Exemple #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonDecode_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.textBoxDecodeFilePath.Text))
            {
                return;
            }

            var image = new Bitmap(this.textBoxDecodeFilePath.Text);

            if (image == null)
            {
                return;
            }

            var          source = new RGBLuminanceSource(image, image.Width, image.Height);
            BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

            //Result result = new MultiFormatReader().decode(bitmap, new Hashtable() { { BarcodeFormat.QR_CODE, "" }, { DecodeHintType.TRY_HARDER, true } });
            Result result = new MicroQRCodeReader().decode(bitmap, new Hashtable()
            {
                //Result result = new QRCodeReader().decode(bitmap, new Hashtable() {
                { DecodeHintType.PURE_BARCODE, "" },
                { DecodeHintType.NEED_RESULT_POINT_CALLBACK, new CResultPointCallback() },
                //{ BarcodeFormat.MICRO_QR_CODE, "" },
                { DecodeHintType.TRY_HARDER, true }
            });
            ParsedResult parsedResult = ResultParser.parseResult(result);

            this.textBoxResult.Text = string.Format("format:{0}, type:{1} \r\nRaw result:{2}\r\nParsed result:{3}",
                                                    result.BarcodeFormat,
                                                    parsedResult.Type,
                                                    result.Text,
                                                    parsedResult.DisplayResult);
            if (result.ResultMetadata != null)
            {
                if (result.ResultMetadata.ContainsKey(ResultMetadataType.ERROR_CORRECTION_LEVEL))
                {
                    var ecl = result.ResultMetadata[ResultMetadataType.ERROR_CORRECTION_LEVEL];
                    this.textBoxResult.Text += "\r\nECL:" + ecl;
                }
            }
            //foreach (DictionaryEntry item in result.ResultMetadata)
            //{
            //    this.textBoxResult.Text += string.Format("\r\n[Key:{0}, Value:{1}]", item.Key, item.Value);
            //}
        }
 public WindowsFormsDemoForm()
 {
     InitializeComponent();
     barcodeReader = new BarcodeReader(null, null, source => UseGlobalHistogramBinarizer ? new GlobalHistogramBinarizer(source) : new HybridBinarizer(source))
     {
         AutoRotate  = true,
         TryInverted = true,
         Options     = new DecodingOptions {
             TryHarder = true
         }
     };
     barcodeReader.ResultPointFound += point =>
     {
         if (point == null)
         {
             resultPoints.Clear();
         }
         else
         {
             resultPoints.Add(point);
         }
     };
     barcodeReader.ResultFound += result =>
     {
         txtType.Text     = result.BarcodeFormat.ToString();
         txtContent.Text += result.Text + Environment.NewLine;
         if (result.ResultMetadata.ContainsKey(ResultMetadataType.UPC_EAN_EXTENSION))
         {
             txtContent.Text += " UPC/EAN Extension: " + result.ResultMetadata[ResultMetadataType.UPC_EAN_EXTENSION].ToString();
         }
         lastResults.Add(result);
         var parsedResult = ResultParser.parseResult(result);
         if (parsedResult != null)
         {
             btnExtendedResult.Visible = !(parsedResult is TextParsedResult);
             txtContent.Text          += "\r\n\r\nParsed result:\r\n" + parsedResult.DisplayResult + Environment.NewLine + Environment.NewLine;
         }
         else
         {
             btnExtendedResult.Visible = false;
         }
     };
     resultPoints = new List <ResultPoint>();
     lastResults  = new List <Result>();
     Renderer     = typeof(BitmapRenderer);
 }
Exemple #22
0
        private static void doTest(String contents,
                                   double latitude,
                                   double longitude,
                                   double altitude,
                                   String query)
        {
            ZXing.Result fakeResult = new ZXing.Result(contents, null, null, BarcodeFormat.QR_CODE);
            ParsedResult result     = ResultParser.parseResult(fakeResult);

            Assert.AreEqual(ParsedResultType.GEO, result.Type);
            GeoParsedResult geoResult = (GeoParsedResult)result;

            Assert.AreEqual(latitude, geoResult.Latitude, EPSILON);
            Assert.AreEqual(longitude, geoResult.Longitude, EPSILON);
            Assert.AreEqual(altitude, geoResult.Altitude, EPSILON);
            Assert.AreEqual(query, geoResult.Query);
        }
Exemple #23
0
        public async Task <OdataApiResponse <TResult> > SendReqeust()
        {
            var uri      = CreateRequestUrl();
            var response = await SendRequestAsnyc(HttpClient, uri);

            if (QueryOptions.Take.HasValue || QueryOptions.Skip.HasValue)
            {
                var(count, data) = await ResultParser.ParseCountedAsync(response);

                return(new OdataApiResponse <TResult>(Projection(data), count, response));
            }
            else
            {
                var data = await ResultParser.ParseAsync(response);

                return(new OdataApiResponse <TResult>(Projection(data), null, response));
            }
        }
        RestMSDomain GetDefaultDomain(ClientOptions options)
        {
            var client = CreateClient(options);

            var response = client.GetAsync(configuration.RestMS.Uri).Result;

            response.EnsureSuccessStatusCode();
            var          entityBody = response.Content.ReadAsStringAsync().Result;
            RestMSDomain domainObject;

            if (!ResultParser.TryParse(entityBody, out domainObject))
            {
                var errorString = string.Format("Could not parse entity body as a domain => {0}", entityBody);
                logger.ErrorFormat(errorString);
                throw new ResultParserException(errorString);
            }
            return(domainObject);
        }
Exemple #25
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="result"></param>
 public BarcodeResult(Result result)
 {
     if (result == null)
     {
         this.IsSuccess = false;
         return;
     }
     this.RawText        = result.Text;
     this.BarcodeFormat  = result.BarcodeFormat;
     this.RawBytes       = result.RawBytes;
     this.ResultMetadata = new Dictionary <ResultMetadataType, object>(result.ResultMetadata);
     this.Timestamp      = result.Timestamp;
     this.ParsedResult   = ResultParser.parseResult(result);
     this.ParsedText     = this.ParsedResult.DisplayResult;
     this.ParsedType     = this.ParsedResult.Type;
     this.ResultRegion   = GetRegion(result);
     this.IsSuccess      = true;
 }
        private static void assertCorrectImage2result(String imageFileName, ExpandedProductParsedResult expected)
        {
            var rssExpandedReader = new RSSExpandedReader();

            var binaryMap = TestCaseUtil.getBinaryBitmap("test/data/blackbox/rssexpanded-1", imageFileName);
            var rowNumber = binaryMap.Height / 2;
            var row       = binaryMap.getBlackRow(rowNumber, null);

            var theResult = rssExpandedReader.decodeRow(rowNumber, row, null);

            Assert.IsNotNull(theResult);

            Assert.AreEqual(BarcodeFormat.RSS_EXPANDED, theResult.BarcodeFormat);

            var result = ResultParser.parseResult(theResult);

            Assert.AreEqual(expected, result);
        }
        public string MESConsole(int iMessageID, string strMessageString)
        {
            string strSuccess = "Success";

            if (iMessageID == 1) //1為 Online
            {
                try
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    string          tt = Server.MapPath("~/App_Data/system.ini");
                    string          t1 = Server.MapPath("system.ini");
                    string          t2 = Server.MapPath("~/system.ini");
                    ResultStructure pResultStructure = ResultParser.GetResult(strMessageString, Server.MapPath("~/App_Data/system.ini"));
                    //ResultStructure pResultStructure = ResultParser.GetResult(strMessageString, Server.MapPath(@"C:\Users\James\Desktop\system.ini"));
                    sw.Stop();

                    strSuccess += string.Format(", CaseName: {0}, ContextID: {1}, PhaseType: {2}, IsAction: {3}, AVMData has {4} Result, ISDInfo NeedMeasure: {5}, ISDInfo Remark: {6}, Elapsed: {7} sec",
                                                pResultStructure.CaseName,
                                                pResultStructure.ContextID,
                                                pResultStructure.Type,
                                                pResultStructure.IsAction,
                                                pResultStructure.AVMData.Rows.Count,
                                                pResultStructure.mISDInfo.NeedMeasure,
                                                pResultStructure.mISDInfo.Remark,
                                                (double)sw.ElapsedMilliseconds / 1000
                                                );

                    // 執行想要的行為
                    DoSomething(pResultStructure.ContextID);
                }
                catch (System.Exception ex)
                {
                    strSuccess = "Fail, " + ex.ToString();
                }
            }
            else if (iMessageID == 0) //0為 Offline
            {
                //if Offline do nothing
                strSuccess = "Success, do nothing";
            }

            return(strSuccess);
        }
Exemple #28
0
        /// <summary>
        /// Makes a transaction when there exist a verified agreement between the client and the merchant.
        /// In case of payment failure: Please use a minimum of 30 minutes delay between the first try and the second. If the
        /// transaction still fails, please wait a couple of hours before the next try. After a total period of 8 hours, you should
        /// stop trying to charge the customer.
        /// Documentation: http://www.payexpim.com/technical-reference/pxagreement/autopay/
        /// </summary>
        /// <param name="request">The parameters to the AutoPay request</param>
        public async Task <AutoPayResult> AutoPay(AutoPayRequest request)
        {
            // Validation
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request), "request is required");
            }

            // Build string for md5 including all fields except empty strings and description field
            var hashInput = new StringBuilder();

            hashInput.Append(Account.AccountNumber);
            hashInput.Append(request.AgreementRef);
            hashInput.Append(request.Amount.ToPayEx());
            hashInput.Append(request.ProductNumber);
            hashInput.Append(request.Description);
            hashInput.Append(request.OrderID);
            hashInput.Append(request.PurchaseOperation.ToPayEx());
            hashInput.Append(request.CurrencyCode);
            // Add encryption key at the end of string to be hashed
            hashInput.Append(Account.EncryptionKey);
            // Create a hash string from the parameters
            string hash;

            MD5Hash.Hash(hashInput.ToString(), out hash);

            // Invoke Initialize method on external PayEx PxOrder web service
            var payexAgreement = GetPxAgreementClient();
            var xmlReturn      = await payexAgreement.AutoPay3Async(
                Account.AccountNumber,
                request.AgreementRef ?? "",
                request.Amount.ToPayEx(),
                request.ProductNumber ?? "",
                request.Description ?? "",
                request.OrderID ?? "",
                request.PurchaseOperation.ToPayEx(),
                request.CurrencyCode ?? "",
                hash);

            // Parse the result
            var result = ResultParser.ParseAutoPayResult(xmlReturn);

            return(result);
        }
Exemple #29
0
        public async Task <bool> BuildAsync()
        {
            if (Finished)
            {
                return(true);
            }

            await VerifyBuildAsync();

            if (Finished)
            {
                return(BuildTask.Succeeded);
            }

            ExecutionResult = TestExecutingResult.Building;
            await BuildTask.RunAsync();

            if (!BuildTask.Succeeded)
            {
                if (BuildTask.TimedOut)
                {
                    ExecutionResult = TestExecutingResult.TimedOut;
                }
                else
                {
                    ExecutionResult = TestExecutingResult.BuildFailure;
                }
                FailureMessage = BuildTask.FailureMessage;
                if (!string.IsNullOrEmpty(BuildTask.KnownFailure))
                {
                    KnownFailure = BuildTask.KnownFailure;
                }
                if (Harness.InCI && BuildTask is MSBuildTask projectTask)
                {
                    ResultParser.GenerateFailure(Logs, "build", projectTask.TestName, projectTask.Variation, $"App Build {projectTask.TestName} {projectTask.Variation}", $"App could not be built {FailureMessage}.", projectTask.BuildLog.FullPath, Harness.XmlJargon);
                }
            }
            else
            {
                ExecutionResult = TestExecutingResult.Built;
            }
            return(BuildTask.Succeeded);
        }
        public void testGeo(String contents,
                            double latitude,
                            double longitude,
                            double altitude,
                            String query,
                            String uri)
        {
            ZXing.Result fakeResult = new ZXing.Result(contents, null, null, BarcodeFormat.QR_CODE);
            ParsedResult result     = ResultParser.parseResult(fakeResult);

            Assert.AreEqual(ParsedResultType.GEO, result.Type);
            GeoParsedResult geoResult = (GeoParsedResult)result;

            Assert.AreEqual(latitude, geoResult.Latitude, EPSILON);
            Assert.AreEqual(longitude, geoResult.Longitude, EPSILON);
            Assert.AreEqual(altitude, geoResult.Altitude, EPSILON);
            Assert.AreEqual(query, geoResult.Query);
            Assert.AreEqual(uri ?? contents.ToLower(), geoResult.GeoURI);
        }
        internal void MakeApiCall(string method,
                                  string apiCall,
                                  byte[] postData,
                                  ResultParser resultParser)
        {
            bool           useStreaming = apiCall.EndsWith("live.xml");
            string         host         = useStreaming ? "streaming.campfirenow.com" : m_Domain;
            UriBuilder     uri          = new UriBuilder("https", host, -1, apiCall);
            HttpWebRequest request      = (HttpWebRequest)WebRequest.Create(uri.Uri);

            request.Accept      = "text/javascript, text/html, application/xml, text/xml, */*";
            request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
            request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(m_AuthToken));
            request.Method = method;
            if (postData != null)
            {
                request.ContentType = "application/xml";
                using (Stream postDataStream = request.GetRequestStream())
                {
                    postDataStream.Write(postData, 0, postData.Length);
                    postDataStream.Close();
                }
            }

            using (WebResponse response = request.GetResponse())
            {
                using (Stream responseStream = response.GetResponseStream())
                {
                    using (XmlReader reader = XmlReader.Create(responseStream, m_ReaderSettings))
                    {
                        resultParser(this, reader);

                        if (useStreaming)
                        {
                            request.Abort();
                        }
                        reader.Close();
                    }
                    responseStream.Close();
                }
                response.Close();
            }
        }
        private static void doTest(String contents,
                                   String[] tos,
                                   String[] ccs,
                                   String[] bccs,
                                   String subject,
                                   String body)
        {
            var fakeResult = new ZXing.Result(contents, null, null, BarcodeFormat.QR_CODE);
            var result     = ResultParser.parseResult(fakeResult);

            Assert.AreEqual(ParsedResultType.EMAIL_ADDRESS, result.Type);
            var emailResult = (EmailAddressParsedResult)result;

            Assert.AreEqual(tos, emailResult.Tos);
            Assert.AreEqual(ccs, emailResult.CCs);
            Assert.AreEqual(bccs, emailResult.BCCs);
            Assert.AreEqual(subject, emailResult.Subject);
            Assert.AreEqual(body, emailResult.Body);
        }
 public WindowsFormsDemoForm()
 {
     InitializeComponent();
     barcodeReader = new BarcodeReader
     {
         AutoRotate  = true,
         TryInverted = true,
         Options     = new DecodingOptions {
             TryHarder = true
         }
     };
     barcodeReader.ResultPointFound += point =>
     {
         if (point == null)
         {
             resultPoints.Clear();
         }
         else
         {
             resultPoints.Add(point);
         }
     };
     barcodeReader.ResultFound += result =>
     {
         txtType.Text     = result.BarcodeFormat.ToString();
         txtContent.Text += result.Text + Environment.NewLine;
         lastResults.Add(result);
         var parsedResult = ResultParser.parseResult(result);
         if (parsedResult != null)
         {
             btnExtendedResult.Visible = !(parsedResult is TextParsedResult);
             txtContent.Text          += "\r\n\r\nParsed result:\r\n" + parsedResult.DisplayResult + Environment.NewLine + Environment.NewLine;
         }
         else
         {
             btnExtendedResult.Visible = false;
         }
     };
     resultPoints = new List <ResultPoint>();
     lastResults  = new List <Result>();
     Renderer     = typeof(BitmapRenderer);
 }
Exemple #34
0
        public void BingRank_HappyFlow()
        {
            // Arrange
            var mockService = new Mock <ICommonSearch>();

            mockService.Setup(service => service.GetBingResult("www.anz.com.au", "e-settlements", "10"))
            .Returns(GetBingResults());
            var logger        = Mock.Of <ILogger <RankController> >();
            var parserLogger  = Mock.Of <ILogger <ResultParser> >();
            var configuration = TestHelper.GetApiConfig();
            var cache         = TestHelper.GetGoogleCache();
            var parser        = new ResultParser(configuration, parserLogger, cache);
            var searchParam   = TestHelper.GetBingParam();
            var controller    = new RankController(logger, mockService.Object, parser, cache, configuration);
            // Act
            var result = controller.GetBingRank(searchParam);

            //Assert
            Assert.Equal("6", ((ObjectResult)result.Result).Value);
        }
Exemple #35
0
        private void Open_Result(object sender, RoutedEventArgs e)
        {
            OpenFileDialog resultFile = new OpenFileDialog
            {
                Filter = "HTML Files (*.html)|*.html"
            };

            if (resultFile.ShowDialog() == true)
            {
                string   session  = "Race";
                string[] filePath = resultFile.FileName.Split('\\');
                ResultFileTextBox.Text = filePath[filePath.Length - 1];
                track = TrackParser.Parse(resultFile.FileName);
                Console.WriteLine(track.length);
                ResultParser.Parse(ref drivers, resultFile.FileName, ref session, track.length);
                drivers.Sort();
                track.laps = drivers[1].result.laps;
                PDFGeneration.RacePDFGenerator.OutputPDF(drivers, "Monster Energy NASCAR Cup Series", "Pennzoil 400", track);
            }
        }
        private QRType getQRTypeFromCode(ZXing.Result readQRCode)
        {
            ParsedResult parsed = ResultParser.parseResult(readQRCode);

            switch (parsed.Type)
            {
            case ParsedResultType.ADDRESSBOOK:
                return(QRType.ADDRESSBOOK);

            case ParsedResultType.CALENDAR:
                return(QRType.CALENDAR);

            case ParsedResultType.EMAIL_ADDRESS:
                return(QRType.EMAIL_ADDRESS);

            case ParsedResultType.GEO:
                return(QRType.GEO);

            case ParsedResultType.ISBN:
                return(QRType.ISBN);

            case ParsedResultType.PRODUCT:
                return(QRType.PRODUCT);

            case ParsedResultType.SMS:
                return(QRType.SMS);

            case ParsedResultType.TEL:
                return(QRType.TEL);

            case ParsedResultType.URI:
                return(QRType.URI);

            case ParsedResultType.WIFI:
                return(QRType.WIFI);

            case ParsedResultType.TEXT:
            default:
                return(QRType.TEXT);
            }
        }
Exemple #37
0
        public void GoogleRank_HappyFlow()
        {
            // Arrange
            var mockService = new Mock <ICommonSearch>();

            mockService.Setup(service => service.GetGoogleResult("www.shavershop.com.au", "best men's shaver australia", "5"))
            .Returns(GetGoogleResults());
            var logger        = Mock.Of <ILogger <RankController> >();
            var parserLogger  = Mock.Of <ILogger <ResultParser> >();
            var configuration = TestHelper.GetApiConfig();
            var googleCache   = TestHelper.GetGoogleCache();
            var parser        = new ResultParser(configuration, parserLogger, googleCache);
            var searchParam   = TestHelper.GetSearchParam();

            var controller = new RankController(logger, mockService.Object, parser, googleCache, configuration);
            // Act
            var result = controller.GetGoogleRank(searchParam);

            //Assert
            Assert.Equal("5", ((ObjectResult)result.Result).Value);
        }
Exemple #38
0
        public void ResultFileCommandAction()
        {
            if (selectedSeries != null)
            {
                Microsoft.Win32.OpenFileDialog resultFile = new Microsoft.Win32.OpenFileDialog
                {
                    Filter           = "HTML Files (*.html)|*.html",
                    InitialDirectory = (System.IO.Directory.Exists((series.NR2K3Dir + "\\exports_imports"))) ? series.NR2K3Dir + "\\exports_imports" : "C:\\"
                };

                if (resultFile.ShowDialog() == true)
                {
                    track          = TrackParser.Parse(series.NR2K3Dir, resultFile.FileName);
                    resultFilePath = resultFile.FileName;
                    ResultFile     = resultFile.FileName.Split('\\').Last();
                    Sessions.Clear();
                    ResultParser.GetSessions(resultFile.FileName, Sessions);
                    SelectedSession = (Sessions.Count > 0) ? Sessions[0] : null;
                }
            }
        }
        public void Deserialize_GetTransactionDetailsIsSuccessful_ReturnsAnAddressCollection()
        {
            ResultParser resultParser = new ResultParser();
            TransactionResult result = resultParser.Deserialize<TransactionResult>(Factory.TransactionResult);

            Assert.IsNotNull(result.AddressCollection.MainAddress);
        }
        public void Deserialize_GetTransactionDetailsIsSuccessful_ReturnsSuccessTrue()
        {
            ResultParser resultParser = new ResultParser();
            TransactionResult result = resultParser.Deserialize<TransactionResult>(Factory.TransactionResult);

            Assert.IsNotNull(result.Status);
        }
        public void Deserialize_GetTransactionDetailsIsSuccessful_ReturnsNonEmptyAddress()
        {
            ResultParser resultParser = new ResultParser();
            TransactionResult result = resultParser.Deserialize<TransactionResult>(Factory.TransactionResult);

            Assert.IsNotNullOrEmpty(result.Address);
        }
        public void Deserialize_GetTransactionDetailsResultXml_ReturnsTransactionResultObject()
        {
            ResultParser resultParser = new ResultParser();
            TransactionResult result = resultParser.Deserialize<TransactionResult>(Factory.TransactionResult);

            Assert.IsNotNull(result);
        }
        public void Deserialize_CompleteIsUnsuccessful_ReturnsNonEmptyTransactionErrorCode()
        {
            ResultParser resultParser = new ResultParser();
            CompleteResult result = resultParser.Deserialize<CompleteResult>(Factory.CompleteResultError);

            Assert.IsNotNullOrEmpty(result.ErrorDetails.TransactionErrorCode);
        }