Ejemplo n.º 1
0
        public void Encode_WikipediaSample_ShouldEncodeAztecCodeCorrectly()
        {
            // Arrange
            var content          = "This is an example Aztec symbol for Wikipedia.";
            var expectedDataBits = ImageStringToBools(@"
                +..++...+..++..+..+....
                +....+..++..+.++.++...+
                ++.+++++.+++........+..
                ++........++.+...++++++
                ..+++.+.+..++++....++..
                .+++.++++.+..+.+..++.+.
                ....+++++..++++.+.+..+.
                +...+.+++++++++++..+.++
                +.+..+++.......++++.++.
                +..++.++.+++++.++.+.+++
                +.+....+.+...+.++++...+
                +...+..+.+.+.+.+.++.+..
                ...+.+++.+...+.+..+++..
                ..++++++.+++++.++++++.+
                .++.+.++.......+++.++++
                .+.+...++++++++++++.++.
                .++.+...+++.+++...++...
                .+.......+.++..+..+++..
                .+.+++.++.+.++++.+.++++
                ..+.+.+++.+.+.++++..+..
                ....+.......+........+.
                ....++..+.++.+.+.+...++
                .+.+.++...+.+....+++..+
            ");

            // Act
            var aztec = AztecEncoder.Encode(content) as AztecCode;

            // Assert
            aztec.Should().NotBeNull();
            expectedDataBits.Length.Should().Be(aztec.Dimension * aztec.Dimension);
            for (int i = 0; i < expectedDataBits.Length; i++)
            {
                int x = i % aztec.Dimension;
                int y = i / aztec.Dimension;
                aztec.Get(x, y).Should().Be(expectedDataBits[i], $"of expected bit on index {i}");
            }
        }
Ejemplo n.º 2
0
        public void Encode_ValidContent_ShouldEncodeAztecCodeCorrectly()
        {
            // Arrange
            var content = "Aztec Code is a public domain 2D matrix barcode symbology of nominally square symbols built on a square grid with a distinctive square bullseye pattern at their center.";

            bool[] expectedDataBits = ImageStringToBools(@"
                ....++..++..+..+..+.+++....+.+....+.++...
                .+...++..+.++.++...+......+..+.++.+.....+
                .+.+++..+.+.++..+++.+.++.......++...++..+
                +++......+.+....+....+..+..+.+..++...+.+.
                +.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+
                ..++.+.+.+++.......+...+...++..++.++...+.
                ++..+...+...++++.+.++...+.++.+...++.++.+.
                .+...+.+..++.+.++.++.++++++.++.....+.+.++
                ++.++.+.++++.++++++++.+.+...++.++++.+++..
                .+...+.+..+...++..++.+.+.+..++.+++.+..+++
                .+.+++.++...+++....++.....+.+.+.+++.++..+
                ..+..+.++..++++..+.+..++++.++.++.+++..+.+
                +++.+......+....+++++.+.++.+.+.++.+.+.+.+
                .....+...+++.++..+.+.....+.++++.++.......
                .+..++.+.+...+++++++++++++++.+.++.+.+++..
                ..++........+.+...........++.+...+....+++
                ....+.++.++++++.+++++++++.+..++.....++++.
                .....+++.+..+.+.+.......+.++..+++.++.....
                ++..+..+.+.+.++.+.+++++.+.+++++++...+.+++
                ++++...+...+.++.+.+...+.+.+..+++..++...++
                +.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+
                ..+..+...+....+.+.+...+.+.+..+.++........
                ....++..+++++.+.+.+++++.+.+++..++++.+....
                +..+.+.+....+.+.+.......+.++.++.+++..+.+.
                .+.+++.+.++.+++.+++++++++.++....++..++++.
                ..++.+.+.+++..+...........+++.++.+.+..+..
                ..++++.+....+.++++++++++++++.+...++.++.++
                ......+.+.++...+++++..+++...+...+++....+.
                +...+....+.++++.+..++..++..++.....+.+...+
                +..+...+++++..+.++++.+++..+...++++.+.++.+
                .+++++.......+..+++.+...++.++.++++..++...
                +......+....+.++.++..+..+..+.+.++++......
                ..+.++...+..+...+.++++++.++.+++++++++.+.+
                ..+....++.+...+..+.+.+...+..+++..+...++++
                +..++..++++++......+++.+.......+.+..+..++
                +.++..+.......+++++..++..++++++++..+.+.++
                +.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+
                +.....+..++++..+..+....+....+.+...++.+++.
                +.+.++.+++.+....++..++++..++.+.+..+.+...+
                ...+..+..+..++..+.++.++.+....++...+...+.+
                +...+.....+.+.+..++.+.......+..+..+++....
            ");

            // Act
            var aztec = AztecEncoder.Encode(content) as AztecCode;

            // Assert
            aztec.Should().NotBeNull();
            expectedDataBits.Length.Should().Be(aztec.Dimension * aztec.Dimension);
            for (int i = 0; i < expectedDataBits.Length; i++)
            {
                int x = i % aztec.Dimension;
                int y = i / aztec.Dimension;
                aztec.Get(x, y).Should().Be(expectedDataBits[i], $"of expected bit on index {i}");
            }
        }