public void Render_Barcode1D() { // Arrange IBarcodeIntCS barcode = Code128.Encode("Wikipedia"); var renderer = new SvgRenderer(); // Act string svg; using (var stream = new MemoryStream()) using (var reader = new StreamReader(stream)) { renderer.Render(barcode, stream); stream.Position = 0; svg = reader.ReadToEnd(); } // Assert svg.Length.Should().BeGreaterOrEqualTo(0); string expected; using (Stream stream = typeof(SvgRendererTests).Assembly.GetManifestResourceStream("Barcoder.Renderer.Svg.Tests.ExpectedSvgOutput.txt")) using (var reader = new StreamReader(stream)) expected = reader.ReadToEnd().Replace("\r", "").Replace("\n", ""); var actual = svg.Replace("\r", "").Replace("\n", ""); actual.Should().Be(expected); }
public void Encode(bool includeChecksum, bool fullAsciiMode, string data, string testResult) { IBarcodeIntCS code = Code39.Encode(data, includeChecksum, fullAsciiMode); code.Bounds.X.Should().Be(testResult.Length); code.Bounds.Y.Should().Be(1); code.Metadata.CodeKind.Should().Be(BarcodeType.Code39); 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); }
"1100011101011")] // STOP public void Encode(string txt, string testResult) { IBarcodeIntCS code = Code128Encoder.Encode(txt); code.Bounds.X.Should().Be(testResult.Length); code.Bounds.Y.Should().Be(1); code.Metadata.CodeKind.Should().Be(BarcodeType.Code128); 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); }
public void Encode(bool interleaved, bool includeChecksum, string txt, string testResult) { IBarcodeIntCS code = TwoToFiveEncoder.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); }
public void Encode(string testCode, string testResult, string kind, bool checkContent) { IBarcodeIntCS code = Ean.Encode(testCode); if (checkContent) { code.Content.Should().Be(testCode); } code.Bounds.X.Should().Be(testResult.Length); code.Bounds.Y.Should().Be(1); code.Metadata.CodeKind.Should().Be(kind); 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); }
public void Encode_Checksum() { IBarcodeIntCS code = Code39.Encode("5B79AN", true, true); code.Checksum.Should().Be('M'); }