public void Encode_ShouldReturnTheSameOutputAsExternalEncoder() { // arrange var configuration = new ExternalGeneratorSettings(); var sampleDocument = this.CreateSampleBySquareXmlDocuments(configuration); // The externalEncoded string was obtained from original BySquare implementation: // configuration.Url = "https://app.bysquare.com/api/generateStringCodes"; // configuration.Username = "******"; // configuration.Password = "******"; // var externalEncoder = new BySquareExternalEncoder(configuration, null); // var externalEncoded = externalEncoder.Encode(sampleDocument.Documents[0]); const string externalEncoded = "0007600054C8J2HVP2SVF56AV7DU85T2V2LRVDIAISK7DQTELQ0KET9NVS0ERS41BEJS3LFKRPS29E1LTH" + "G8QC9FCBUD413RVV83BFMBHOSJO74L0H6D3717FPLP8AP5VGS83I2CUQSOL3H000"; // act var internalEncoded = new BySquareInternalEncoder().Encode(sampleDocument.Documents[0]); // assert Assert.AreEqual(externalEncoded, internalEncoded); }
public IActionResult SampleFile() { var serializer = new BySquareXmlSerializer(); var encoder = new BySquareInternalEncoder(); var imageManipulator = new ImageManipulator(this.Environment); var excelManipulator = new ExcelManipulator(encoder, imageManipulator, null); var filePath = Path.Combine(this.Environment.ContentRootPath, "Samples", "platobny_harok.xlsx"); (_, var bySquareDocuments) = excelManipulator.ReadPaymentList(filePath); // alter date to current date bySquareDocuments[0].Payments[0].PaymentDueDate = DateTime.Today.AddDays(1); ViewData["XML"] = serializer.SerializeAsXml(bySquareDocuments[0]); // generate QR code var qrstring = this.Encoder.Encode(bySquareDocuments[0]); var image = imageManipulator.CreateQrCodeWithLogo(qrstring); ViewData["IMAGE"] = imageManipulator.EncodeImageAsBase64String(image); return(View("Sample")); }