Example #1
0
        private static void TestInput(string inputText)
        {
            var sb = new StringBuilder();

            foreach (var moduleSize in new[] { 1, 2, 3 })
            {
                foreach (ErrorCorrectionLevel errorCorrectionLevel in Enum.GetValues(typeof(ErrorCorrectionLevel)).Cast <ErrorCorrectionLevel>())
                {
                    string output = null;

                    try
                    {
                        var bitmapImage = QrCodeExporter.Export(errorCorrectionLevel, inputText, moduleSize, new SolidBrush(Color.Black), new SolidBrush(Color.White));
                        output = QrCodeUtils.GetStringFromQrCode(bitmapImage);
                    }
                    catch (Exception e)
                    {
                        // Assert.Fail("Assert failed, with ModuleSize: {0}, ErrorCorrectionLevel: {1}, Exception: {2}", moduleSize, errorCorrectionLevel, e.Message);
                        sb.AppendLine(String.Format("Assert failed with Exception, with ModuleSize: {0}, ErrorCorrectionLevel: {1}, Exception: {2}", moduleSize, errorCorrectionLevel, e.Message));
                    }

                    //Assert.AreEqual(InputText, output, "Assert failed, with ModuleSize: {0}, ErrorCorrectionLevel: {1}", moduleSize, errorCorrectionLevel);
                    if (inputText != output)
                    {
                        sb.AppendLine(String.Format("Assert failed, with ModuleSize: {0}, ErrorCorrectionLevel: {1}", moduleSize, errorCorrectionLevel));
                    }
                }
            }

            Assert.AreEqual(String.Empty, sb.ToString());
        }
Example #2
0
        public void ErrorCorrectionLevel_Quality_ModuleSize_1_Black_White()
        {
            var bitmapImage = QrCodeExporter.Export(Common.ErrorCorrectionLevel.Q, InputText, 1, new SolidBrush(Color.Black), new SolidBrush(Color.White));

            var output = QrCodeUtils.GetStringFromQrCode(bitmapImage);

            Assert.AreEqual(InputText, output);
        }
        public void GenerateQrCodeComplex()
        {
            var input = @"Köln Düsseldorf 7m5*847OT6%YqMJGU#|,v\4w#e!\dp öäüÄÖÜ \@€";

            var bitmapImage = QrCodeExporter.Export(Common.ErrorCorrectionLevel.M, input, 1, new SolidBrush(Color.Black), new SolidBrush(Color.White));

            var output = QrCodeUtils.GetStringFromQrCode(bitmapImage);

            Assert.AreEqual(input, output);
        }
        public void GenerateQrCodeWitUmlaute()
        {
            var input = "Köln Düsseldorf";

            var bitmapImage = QrCodeExporter.Export(Common.ErrorCorrectionLevel.M, input, 1, new SolidBrush(Color.Black), new SolidBrush(Color.White));

            var output = QrCodeUtils.GetStringFromQrCode(bitmapImage);

            Assert.AreEqual(input, output);
        }