コード例 #1
0
        public void Encode(bool interleaved, bool includeChecksum, string txt, string testResult)
        {
            IBarcodeIntCS code = TwoToFive.Encode(txt, interleaved, includeChecksum);

            code.Bounds.X.Should().Be(testResult.Length);
            code.Bounds.Y.Should().Be(1);
            code.Metadata.CodeKind.Should().Be(interleaved ? BarcodeType.TwoOfFiveInterleaved : BarcodeType.TwoOfFive);
            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);
        }
コード例 #2
0
        public void Encode_InterleavedWithEvenDigitCountAndChecksum_ShouldThrowException()
        {
            Action action = () => TwoToFive.Encode("1234", true, true);

            action.Should().Throw <InvalidOperationException>().WithMessage("Can only encode an even number of digits in interleaved mode");
        }
コード例 #3
0
        public void Encode_InvalidCharacters_ShouldThrowException()
        {
            Action action = () => TwoToFive.Encode("123A", false, false);

            action.Should().Throw <InvalidOperationException>().WithMessage("Can only encode numerical digits (0-9)");
        }