public void Encode_InvalidContentLength_ShouldThrowException() { Action action = () => EanEncoder.Encode("123"); action.Should().Throw <InvalidOperationException>() .WithMessage("Invalid content length. Should be 7 or 12 if the code does not include a checksum, 8 or 13 if the code already includes a checksum"); }
public void Encode_InvalidCode_ShouldThrowException() { Action action = () => EanEncoder.Encode("invalid"); action.Should().Throw <InvalidOperationException>() .WithMessage("Can only encode numerical digits (0-9)"); }
public void Encode_InvalidChecksum_ShouldThrowException() { Action action = () => EanEncoder.Encode("55123458"); action.Should().Throw <InvalidOperationException>() .WithMessage("Checksum mismatch"); }
public void Render_Ean13_IncludeContentAsText() { var renderer = new ImageRenderer(imageFormat: ImageFormat.Png, includeEanContentAsText: true); IBarcode barcode = EanEncoder.Encode("978020137962"); using Stream stream = File.OpenWrite(@"d:\temp\ean-test.png"); renderer.Render(barcode, stream); }
public void Render_Ean8_IncludeContentAsText() { var renderer = new SvgRenderer(includeEanContentAsText: true); IBarcode barcode = EanEncoder.Encode("1234567"); using Stream stream = File.OpenWrite(@"d:\temp\ean-test.svg"); renderer.Render(barcode, stream); }
public void Encode(string testCode, string testResult, string kind, bool checkContent) { IBarcodeIntCS code = EanEncoder.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); }