コード例 #1
0
        public void Encode_NonAsciiCharacterInAsciiMode_ShouldThrowException()
        {
            Action action = () => Code93.Encode("ù", false, true);

            action.Should().Throw <InvalidOperationException>()
            .WithMessage("Only ASCII strings can be encoded");
        }
コード例 #2
0
        public void Encode_ContainsStarInNonAsciiMode_ShouldThrowException()
        {
            Action action = () => Code93.Encode("01*", false, false);

            action.Should().Throw <InvalidOperationException>()
            .WithMessage("Invalid data! Try full ASCII mode");
        }
コード例 #3
0
        public void Encode_UnderscoreInNonAsciiMode_ShouldThrowException()
        {
            Action action = () => Code93.Encode("_", false, false);

            action.Should().Throw <InvalidOperationException>()
            .WithMessage("Invalid data");
        }
コード例 #4
0
        public void Encode(string data, string testResult)
        {
            IBarcode code = Code93.Encode(data, true, false);

            code.Bounds.X.Should().Be(testResult.Length);
            code.Bounds.Y.Should().Be(1);
            code.Metadata.CodeKind.Should().Be(BarcodeType.Code93);
            code.Metadata.Dimensions.Should().Be(1);

            string encoded = string.Empty;
            int    i       = 0;

            foreach (var r in testResult)
            {
                encoded += code.At(i++, 0) ? "1" : "0";
            }
            encoded.Should().Be(testResult);
        }
コード例 #5
0
        public void Encode_UnderscoreInAsciiMode_ShouldNotThrowException()
        {
            Action action = () => Code93.Encode("_", false, true);

            action.Should().NotThrow();
        }