Exemplo n.º 1
0
        public void TestNewLine()
        {
            const string str = "A\r\nB";
            var          bmp = QrCode.Create(str);

            bmp.Save("TestNewLine.bmp", ImageFormat.Bmp);
            var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);

            emf.Save("TestNewLine.emf", ImageFormat.Emf);
            var result = QrCode.ReadAsString(bmp);

            Assert.AreEqual(str, result);
        }
Exemplo n.º 2
0
        public void TestArabic()
        {
            var str = "ه تعبير كان بيستخدم ";
            var bmp = QrCode.Create(str);

            bmp.Save("TestArabic.bmp", ImageFormat.Bmp);
            var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);

            emf.Save("TestArabic.emf", ImageFormat.Emf);
            var result = QrCode.ReadAsString(bmp);

            Assert.AreEqual(str, result);
        }
Exemplo n.º 3
0
        public void TestSpecialChars()
        {
            var str = "!\"§$%&/()=??`*'Äöüä;><,.-#d+´ß";
            var bmp = QrCode.Create(str);

            bmp.Save("TestSpecialChars.bmp", ImageFormat.Bmp);
            var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);

            emf.Save("TestSpecialChars.emf", ImageFormat.Emf);
            var result = QrCode.ReadAsString(bmp);

            Assert.AreEqual(str, result);
        }
Exemplo n.º 4
0
        public void TestChineseHanzuKanji()
        {
            var str = "梨阜埼茨栃";
            var bmp = QrCode.Create(str);

            bmp.Save("TestChineseHanzuKanji.bmp", ImageFormat.Bmp);
            var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);

            emf.Save("TestChineseHanzuKanji.emf", ImageFormat.Emf);
            var result = QrCode.ReadAsString(bmp);

            Assert.AreEqual(str, result);
        }
Exemplo n.º 5
0
        public void TestRussisch()
        {
            var str = "ў дачыненні да іншых скончаных";
            var bmp = QrCode.Create(str);

            bmp.Save("TestRussisch.bmp", ImageFormat.Bmp);
            var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);

            emf.Save("TestRussisch.emf", ImageFormat.Emf);
            var result = QrCode.ReadAsString(bmp);

            Assert.AreEqual(str, result);
        }
Exemplo n.º 6
0
        public void TestGeorgisch()
        {
            var str = "აზრდოებელი დედა) თანამედროვე მნიშვნელობ";
            var bmp = QrCode.Create(str);

            bmp.Save("TestGeorgisch.bmp", ImageFormat.Bmp);
            var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);

            emf.Save("TestGeorgisch.emf", ImageFormat.Emf);
            var result = QrCode.ReadAsString(bmp);

            Assert.AreEqual(str, result);
        }
Exemplo n.º 7
0
        public void CheckRandomCharWithPattern(QRErrorLevel errLevel)
        {
            Trace.WriteLine(errLevel);
            var    watch       = System.Diagnostics.Stopwatch.StartNew();
            int    numSuccess  = 0;
            int    numFails    = 0;
            int    sampleFail  = 0;
            double successRate = 0;
            double elapsedMs   = 0;

            for (int i = 999; i >= 0; i--)
            {
                string str = "";
                try
                {
                    var    mandant   = FakerRandom.Rand.Next(999);
                    int    anzSeiten = FakerRandom.Rand.Next(99);
                    var    numSeite  = FakerRandom.Rand.Next(anzSeiten);
                    string codGoTyp  = Lorem.GetWord();
                    string codGoNr   = Lorem.GetWord();
                    int    codHuelle = FakerRandom.Rand.Next(9999);
                    str = $"SAMDMS: MANDANT ={mandant}; NUMSEITE = {numSeite}; ANZSEITEN ={anzSeiten}; ABLAGE = (COD_GO_TYP = {codGoTyp}; COD_GO_NR ={codGoNr};COD_HUELLE ={codHuelle})";
                    var bmp = QrCode.Create(str, errLevel);
                    bmp.Save("TestRandomCharWithPattern.bmp", ImageFormat.Bmp);
                    var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);
                    emf.Save("TestRandomCharWithPattern.emf", ImageFormat.Emf);
                    var result = QrCode.ReadAsString(bmp);
                    Assert.AreEqual(str, result);
                    numSuccess++;
                }
                catch (System.Exception x)
                {
                    numFails++;
                    if (sampleFail == 0)
                    {
                        Trace.WriteLine(message: $"{x.Message} with this Input: \n{str}");
                    }
                    sampleFail = 1;
                }
            }
            successRate = System.Math.Round((double)numSuccess / (numSuccess + numFails) * 100, 2);
            Trace.WriteLine("Success: " + numSuccess + ", Fail: " + numFails);
            Trace.WriteLine("Successrate: " + successRate + "%");
            watch.Stop();

            elapsedMs = watch.ElapsedMilliseconds / 1000;
            Trace.WriteLine("Elapsed Time: " + elapsedMs);
            Trace.WriteLine("");
        }
Exemplo n.º 8
0
        public void TestMaxTextLength()
        {
            var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-1234567890_abcdefghijklmnopqrstuvwxyz"; //64

            QrCode.Create(str); str += str;                                               //128
            QrCode.Create(str); str += str;                                               //256
            QrCode.Create(str); str += str;                                               //512
            QrCode.Create(str); str += str;                                               //1024
            QrCode.Create(str); str += str;                                               //2048 max: 1273.
            var bmp = QrCode.Create(str, QRErrorLevel.LevelM);

            bmp.Save("TestMaxTextLength.bmp", ImageFormat.Bmp);
            var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);

            emf.Save("TestMaxTextLength.emf", ImageFormat.Emf); str += str;    //4096 max: 2953
            QrCode.Create(str, QREncodeMode.AlphaNumber, QRErrorLevel.LevelL); //8192 max:
        }
Exemplo n.º 9
0
        public void TestJapaneseHiragana()
        {
            var str = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむ";
            var bmp = QrCode.Create(str);

            bmp.Save("TestJapaneseHiragana.bmp", ImageFormat.Bmp);
            var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);

            emf.Save("TestJapaneseHiragana.emf", ImageFormat.Emf);
            var result = QrCode.ReadAsString(bmp);

            Assert.IsNull(result, "This issue has been fixed by Aspose");
            var bytes = QrCode.ReadAsBinary(bmp);

            Assert.IsNull(bytes, "This issue has been fixed by Aspose");
            //Assert.AreEqual(str, result); //works with Mobile Phone
        }
Exemplo n.º 10
0
        public void TestJapaneseKatakana()
        {
            var str = "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミム";
            var bmp = QrCode.Create(str);

            bmp.Save("TestJapaneseKatakana.bmp", ImageFormat.Bmp);
            var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);

            emf.Save("TestJapaneseKatakana.emf", ImageFormat.Emf);
            var result = QrCode.ReadAsString(bmp);

            Assert.IsNull(result, "This issue has been fixed by Aspose");
            var bytes = QrCode.ReadAsBinary(bmp);

            Assert.IsNull(bytes, "This issue has been fixed by Aspose");
            //Assert.AreEqual(str, result); //works with Mobile Phone
        }
Exemplo n.º 11
0
        public void TestRandomCharWithPattern2()
        {
            var    mandant   = FakerRandom.Rand.Next(999);
            int    anzSeiten = FakerRandom.Rand.Next(99);
            var    numSeite  = FakerRandom.Rand.Next(anzSeiten);
            string codGoTyp  = Lorem.GetWord();
            string codGoNr   = Lorem.GetWord();
            int    codHuelle = FakerRandom.Rand.Next(9999);
            //var str = "SAMDMS: MANDANT =181; NUMSEITE = 4; ANZSEITEN =7; ABLAGE = (COD_GO_TYP = facilis; COD_GO_NR =tempore;COD_HUELLE =3258)";
            var str = "SAMDMS: MANDANT =922; NUMSEITE = 6; ANZSEITEN =76; ABLAGE = (COD_GO_TYP = dignissimos; COD_GO_NR =qui;COD_HUELLE =6834)";
            var bmp = QrCode.Create(str);

            bmp.Save("C:\\Users\\taod\\Downloads\\TestRandomCharWithPattern.bmp", ImageFormat.Bmp);
            var emf = QrCode.CreateEmf(str, QREncodeMode.Binary, QRErrorLevel.LevelM);

            emf.Save("TestRandomCharWithPattern.emf", ImageFormat.Emf);
            var result = QrCode.ReadAsString(bmp);

            Assert.AreEqual(str, result);
        }
Exemplo n.º 12
0
        public void TestMaxTNumberLength()
        {
            var str = "1234567890";

            QrCode.Create(str); str += str;                           //20
            QrCode.Create(str); str += str;                           //40
            QrCode.Create(str); str += str;                           //80
            QrCode.Create(str); str += str;                           //160
            QrCode.Create(str); str += str;                           //320
            QrCode.Create(str); str += str;                           //640
            QrCode.Create(str); str += str;                           //1280
            QrCode.Create(str, QREncodeMode.AlphaNumber); str += str; //2560 max: 1852
            QrCode.Create(str, QREncodeMode.Numeric); str     += str; //5120 max: 4296
            Image bmp = QrCode.Create(str, QREncodeMode.Numeric, QRErrorLevel.LevelL);

            bmp.Save("TestMaxTNumberLength.bmp", ImageFormat.Bmp);
            Image emf = QrCode.CreateEmf(str, QREncodeMode.Numeric, QRErrorLevel.LevelL);

            emf.Save("TestMaxTNumberLength.emf", ImageFormat.Emf); str += str; //10240 max: 7089.
            QrCode.Create(str, QREncodeMode.Numeric, QRErrorLevel.LevelL);     //20480
        }