Exemplo n.º 1
0
        public void TooFewLines()
        {
            Bill bill = SampleData.CreateExample2();

            bill.UnstructuredMessage = null;
            TestHelper.NormalizeSourceBill(bill);
            string qrText = QRBill.EncodeQrCodeText(bill);

            qrText = qrText[0..^ 5];
Exemplo n.º 2
0
 public void CreateTextError1()
 {
     Assert.Throws <QRBillValidationException>(() =>
     {
         Bill bill   = SampleData.CreateExample4();
         bill.Amount = -0.01m;
         QRBill.EncodeQrCodeText(bill);
     });
 }
 private void CreateText5()
 {
     Assert.Throws <QRBillValidationException>(() =>
     {
         Bill bill   = SampleData.CreateExample4();
         bill.Amount = 0.0m;
         QRBill.EncodeQrCodeText(bill);
     });
 }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        public void DecodeText3()
        {
            Bill bill = SampleData.CreateExample3();

            TestHelper.NormalizeSourceBill(bill);
            Bill bill2 = QRBill.DecodeQrCodeText(QRBill.EncodeQrCodeText(bill));

            TestHelper.NormalizeDecodedBill(bill2);
            Assert.Equal(bill, bill2);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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 DecodeText2()
        {
            Bill bill = SampleData.CreateExample2();

            NormalizeSourceBill(bill);
            Bill bill2 = QRBill.DecodeQrCodeText(QRBill.EncodeQrCodeText(bill));

            NormalizeDecodedBill(bill2);
            Assert.Equal(bill, bill2);
        }
Exemplo n.º 9
0
        public void DecodeText4()
        {
            Bill bill = SampleData.CreateExample4();

            bill.Format = new BillFormat(); // set default values
            TestHelper.NormalizeSourceBill(bill);
            Bill bill2 = QRBill.DecodeQrCodeText(QRBill.EncodeQrCodeText(bill));

            TestHelper.NormalizeDecodedBill(bill2);
            Assert.Equal(bill, bill2);
        }
Exemplo n.º 10
0
        public void TooManyLines()
        {
            Bill bill = SampleData.CreateExample1();

            TestHelper.NormalizeSourceBill(bill);
            string qrText = QRBill.EncodeQrCodeText(bill) + "\n\n";
            QRBillValidationException err = Assert.Throws <QRBillValidationException>(
                () => QRBill.DecodeQrCodeText(qrText));

            TestHelper.AssertSingleError(err.Result, ValidationConstants.KeyValidDataStructure, ValidationConstants.FieldQrType);
        }
Exemplo n.º 11
0
        public void TooFewLines()
        {
            Bill bill = SampleData.CreateExample2();

            bill.UnstructuredMessage = null;
            TestHelper.NormalizeSourceBill(bill);
            string qrText = QRBill.EncodeQrCodeText(bill);

            qrText = qrText.Substring(0, qrText.Length - 5);
            QRBillValidationException err = Assert.Throws <QRBillValidationException>(
                () => QRBill.DecodeQrCodeText(qrText));

            TestHelper.AssertSingleError(err.Result, ValidationConstants.KeyValidDataStructure, ValidationConstants.FieldQrType);
        }
Exemplo n.º 12
0
        public void NoNLAfterEPD()
        {
            Bill bill = SampleData.CreateExample2();

            TestHelper.NormalizeSourceBill(bill);
            string qrText = QRBill.EncodeQrCodeText(bill);

            Assert.EndsWith("EPD", qrText);

            Bill bill2 = QRBill.DecodeQrCodeText(qrText);

            TestHelper.NormalizeDecodedBill(bill2);
            Assert.Equal(bill, bill2);
        }
Exemplo n.º 13
0
        public void CreateText5()
        {
            Bill bill = SampleQRCodeText.CreateBillData5();

            Assert.Equal(SampleQRCodeText.CreateQrCodeText5(false), QRBill.EncodeQrCodeText(bill));
        }
Exemplo n.º 14
0
        private void CreateText4()
        {
            Bill bill = SampleQRCodeText.CreateBillData4();

            Assert.Equal(SampleQRCodeText.CreateQrCodeText4(false), QRBill.EncodeQrCodeText(bill));
        }