public void Code128Text() { var bp = BarcodePattern.GetNewCode128("ABC"); Assert.Equal("2-1-1-4-1-2-1-1-1-3-2-3-1-3-1-1-2-3-1-3-1-3-2-1-2-1-2-2-2-2-2-3-3-1-1-1-2", ToPatternString(bp.GetInterleavedPattern())); Assert.Equal("██ █ █ █ █ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ███ █ ██", ToPatternString(bp.GetBinaryPattern())); Assert.Equal(bp.GetBinaryPattern().Length, bp.GetPatternWidth()); }
public void Code128WriteTransparentPng() { var bp = BarcodePattern.GetNewCode128("1234"); var memStream = new MemoryStream(); bp.SaveAsPng(memStream, Color.Blue, Color.Transparent); //bp.SaveAsPng(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "code128-32.png")); Assert.Equal(174, memStream.Length); Assert.Equal("89504E470D0A1A0A0000000D494844520000003F0000000F0806000000532517720000007549444154789CED95C10EC0200843FBFF3FFD16B29938C2C261070EF640AC48151051804E154D3B8083672409EF891E0D37CE7A25DDBE1698C696864B71EE8E95F6D6075F451CAA6C29880BC78883C7379FAB61AF8AC034B6345C92AD5CF6F8CD4715C80D0F77FBD513E4AF8EFFFFFC69A2690770F08C24E102AC515D030000000049454E44AE426082", BitConverter.ToString(memStream.ToArray()).Replace("-", "")); }
public void Code128WritePng() { var bp = BarcodePattern.GetNewCode128("1234"); var memStream = new MemoryStream(); bp.SaveAsPng(memStream); //bp.SaveAsPng(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "code128-24.png")); Assert.Equal(158, memStream.Length); Assert.Equal("89504E470D0A1A0A0000000D494844520000003F0000000F0802000000DC4780250000006549444154789CED94510AC0300843BDFFA533E947964D1C8C0DA4907C149B3E4A28D6C0CE8AE9009F14D3017E4A1F4B5805C4D12DCD07A08315A83774BC1EA1026775E5E8E896269D0A74B002F5868E777ABF7D2ADB20D75B41C19DE35F0BCF1CBC99983BCAE9E77400667F9C630000000049454E44AE426082", BitConverter.ToString(memStream.ToArray()).Replace("-", "")); }
public void Code128InvalidValue() { Assert.Throws <ArgumentOutOfRangeException>(() => { var _ = BarcodePattern.GetNewCode128("Č"); }); }
public void Code128NullValue() { Assert.Throws <ArgumentNullException>(() => { var _ = BarcodePattern.GetNewCode128(null); }); }