private void GenerateWithFailingCanvas() { Bill bill = SampleData.CreateExample1(); FailingCanvas canvas = new FailingCanvas(); bill.Format.OutputSize = OutputSize.QrBillOnly; QRBill.Draw(bill, canvas); }
private void GenerateAndCompareBill(Bill bill, GraphicsFormat graphicsFormat, SeparatorType separatorType, string expectedFileName) { bill.Format.GraphicsFormat = graphicsFormat; bill.Format.SeparatorType = separatorType; byte[] imageData = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(imageData, expectedFileName); }
public void DecodeMissingEpd() { string invalidText = SampleQRCodeText.CreateQrCodeText1(false).Replace("EPD", "E_P"); QRBillValidationException err = Assert.Throws <QRBillValidationException>( () => QRBill.DecodeQrCodeText(invalidText)); TestHelper.AssertSingleError(err.Result, ValidationConstants.KeyValidDataStructure, ValidationConstants.FieldTrailer); }
public void DecodeInvalidNumber() { string invalidText = SampleQRCodeText.CreateQrCodeText1(false).Replace("3949.75", "1239d49.75"); QRBillValidationException err = Assert.Throws <QRBillValidationException>( () => QRBill.DecodeQrCodeText(invalidText)); TestHelper.AssertSingleError(err.Result, ValidationConstants.KeyValidNumber, ValidationConstants.FieldAmount); }
private Task GenerateAndCompareBill(Bill bill, OutputSize outputSize, GraphicsFormat graphicsFormat) { bill.Format.OutputSize = outputSize; bill.Format.GraphicsFormat = graphicsFormat; bill.Format.FontFamily = "Arial,\"Liberation Sans\""; byte[] imageData = QRBill.Generate(bill); return(VerifyImages.VerifyPng(imageData)); }
public void CreateTextError1() { Assert.Throws <QRBillValidationException>(() => { Bill bill = SampleData.CreateExample4(); bill.Amount = -0.01m; QRBill.EncodeQrCodeText(bill); }); }
public void CreateQrBillFrench() { Bill bill = SampleData.CreateExample1(); bill.Format.GraphicsFormat = GraphicsFormat.SVG; bill.Format.Language = Language.FR; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, "qrbill_fr.svg"); }
public void CreateQrBill5() { Bill bill = SampleData.CreateExample3(); bill.Format.OutputSize = OutputSize.QrBillWithHorizontalLine; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, "qrbill_ex5.svg"); }
public void CreateQrBill4() { Bill bill = SampleData.CreateExample4(); bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, "qrbill_ex4.svg"); }
private void QrCodeAsSvg4() { Bill bill = SampleData.CreateExample4(); bill.Format.OutputSize = OutputSize.QrCodeOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, "qrcode_ex4.svg"); }
private void CreateText5() { Assert.Throws <QRBillValidationException>(() => { Bill bill = SampleData.CreateExample4(); bill.Amount = 0.0m; QRBill.EncodeQrCodeText(bill); }); }
public Task CreateQrBillFrench() { Bill bill = SampleData.CreateExample1(); bill.Format.GraphicsFormat = GraphicsFormat.SVG; bill.Format.Language = Language.FR; byte[] svg = QRBill.Generate(bill); return(VerifyImages.VerifySvg(svg)); }
public Task CreateQrBill5() { Bill bill = SampleData.CreateExample3(); bill.Format.OutputSize = OutputSize.QrBillExtraSpace; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); return(VerifyImages.VerifySvg(svg)); }
public void PdfSaveAs() { Bill bill = SampleData.CreateExample4(); using PDFCanvas canvas = new PDFCanvas(QRBill.A4PortraitWidth, QRBill.A4PortraitHeight); QRBill.Draw(bill, canvas); canvas.SaveAs("qrbill.pdf"); }
public Task QrCodeAsSvg4() { Bill bill = SampleData.CreateExample4(); bill.Format.OutputSize = OutputSize.QrCodeOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); return(VerifyImages.VerifySvg(svg)); }
private static void GenerateWithInvalidData1() { Bill bill = SampleData.CreateExample1(); bill.Creditor.Name = " "; bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.PDF; QRBill.Generate(bill); }
public void PngSaveAs() { Bill bill = SampleData.CreateExample6(); using PNGCanvas canvas = new PNGCanvas(QRBill.QrBillWidth, QRBill.QrBillHeight, 144, "Helvetica, Arial, \"Liberation Sans\""); QRBill.Draw(bill, canvas); canvas.SaveAs("qrbill.png"); }
public void TooFewLines() { Bill bill = SampleData.CreateExample2(); bill.UnstructuredMessage = null; TestHelper.NormalizeSourceBill(bill); string qrText = QRBill.EncodeQrCodeText(bill); qrText = qrText[0..^ 5];
public void SvgSaveAs() { Bill bill = SampleData.CreateExample2(); using SVGCanvas canvas = new SVGCanvas(QRBill.A4PortraitWidth, QRBill.A4PortraitHeight, "Helvetica, Arial, Sans"); QRBill.Draw(bill, canvas); canvas.SaveAs("qrbill.svg"); }
private void PrintQRBill(PrintPageEventArgs e) { // ouput size for QR bill: 210 x 297mm bill.Format.OutputSize = OutputSize.A4PortraitSheet; // print QR bill at bottom of page e.Graphics.PageUnit = GraphicsUnit.Millimeter; using SystemDrawingCanvas canvas = new SystemDrawingCanvas(e.Graphics, 0, 297, 1, "Arial"); QRBill.Draw(bill, canvas); }
public void DecodeTextB2() { Bill bill = SampleQRCodeText.CreateBillData2(); TestHelper.NormalizeSourceBill(bill); Bill bill2 = QRBill.DecodeQrCodeText(SampleQRCodeText.CreateQrCodeText2(false)); TestHelper.NormalizeDecodedBill(bill2); Assert.Equal(bill, bill2); }
public void DecodeText3() { Bill bill = SampleData.CreateExample3(); TestHelper.NormalizeSourceBill(bill); Bill bill2 = QRBill.DecodeQrCodeText(QRBill.EncodeQrCodeText(bill)); TestHelper.NormalizeDecodedBill(bill2); Assert.Equal(bill, bill2); }
public void DecodeInvalidRefType() { Bill bill = SampleData.CreateExample3(); string qrText = QRBill.EncodeQrCodeText(bill); qrText = qrText.Replace("SCOR", "XXXX"); Bill bill2 = QRBill.DecodeQrCodeText(qrText); Assert.Equal("XXXX", bill2.ReferenceType); }
private void DecodeTextB1B() { Bill bill = SampleQRCodeText.CreateBillData1(); TestHelper.NormalizeSourceBill(bill); Bill bill2 = QRBill.DecodeQrCodeText(SampleQRCodeText.CreateQrCodeText1(true)); TestHelper.NormalizeDecodedBill(bill2); Assert.Equal(bill, bill2); }
public void WithAlternativeSchemes() { Bill bill = SampleData.CreateExample1(); TestHelper.NormalizeSourceBill(bill); Bill bill2 = QRBill.DecodeQrCodeText(QRBill.EncodeQrCodeText(bill) + "\n"); TestHelper.NormalizeDecodedBill(bill2); Assert.Equal(bill, bill2); }
private void DecodeTextB1A() { Bill bill = SampleQRCodeText.CreateBillData1(); NormalizeSourceBill(bill); Bill bill2 = QRBill.DecodeQrCodeText(SampleQRCodeText.CreateQrCodeText1(false)); NormalizeDecodedBill(bill2); Assert.Equal(bill, bill2); }
private void DecodeText2() { Bill bill = SampleData.CreateExample2(); NormalizeSourceBill(bill); Bill bill2 = QRBill.DecodeQrCodeText(QRBill.EncodeQrCodeText(bill)); NormalizeDecodedBill(bill2); Assert.Equal(bill, bill2); }
public Task SvgWithChallengingCharacters() { Bill bill = SampleData.CreateExample1(); bill.UnstructuredMessage = "<h1>&&\"ff\"'t'"; bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); return(VerifyImages.VerifySvg(svg)); }
public void CreateTextEmptyReference() { Bill bill = SampleQRCodeText.CreateBillData3(); ValidationResult result = QRBill.Validate(bill); Assert.False(result.HasErrors); bill = result.CleanedBill; bill.Reference = ""; Assert.Equal(SampleQRCodeText.CreateQrCodeText3(false), QRBill.EncodeQrCodeText(bill)); }
private static void GenerateWithInvalidData3() { Bill bill = SampleData.CreateExample1(); bill.Reference = "RF1234"; bill.Currency = "XXX"; bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.PDF; QRBill.Generate(bill); }