Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat new test, fix update netstandard2.1 #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions NetBarcode.Tests/BarcodeTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Png;
using System.Collections;
using Xunit.Abstractions;

namespace NetBarcode.Tests
Expand Down Expand Up @@ -63,5 +64,81 @@ public void Code39E()
var expected = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOgAAAB0CAYAAACPDX5AAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB00lEQVR4nO3TQWrDMBQAURlysPZkPVp7M3eTgmkwRLGgU3gPsrCw8iXD3MYYb/ff177vn+Nu27b34/rxeXb91ffOzrN6zuz9/9v9ZuesmP/sdzx77+r+ld9p9b1n1n8C/RiPfq8fn2fXX33v7Dyr58zef9Xcs3l/PWfF/CvnWrH/2XOu/r8r+x/WbwPIEiiECRTCBAphAoUwgUKYQCFMoBAmUAgTKIQJFMIECmEChTCBQphAIUygECZQCBMohAkUwgQKYQKFMIFCmEAhTKAQJlAIEyiECRTCBAphAoUwgUKYQCFMoBAmUAgTKIQJFMIECmEChTCBQphAIUygECZQCBMohAkUwgQKYQKFMIFCmEAhTKAQJlAIEyiECRTCBAphAoUwgUKYQCFMoBAmUAgTKIQJFMIECmEChTCBQphAIUygECZQCBMohAkUwgQKYQKFMIFCmEAhTKAQJlAIEyiECRTCBAphAoUwgUKYQCFMoBAmUAgTKIQJFMIECmEChTCBQphAIUygECZQCBMohAkUwgQKYQKFMIFCmEAhTKAQJlAIEyiECRTCBAphAoUwgUKYQCFMoBAmUAgTKIQJFMIECmEChTCBQphAIUygECZQCBMohH0DvzgX405Hw8QAAAAASUVORK5CYII=";
Assert.Equal(expected, base64);
}

[Fact]
public void CodeCode128()
{
var barcode = new Barcode("HELLO!", Type.Code128A, false, 200, 50);
var image = barcode.GetImage();

Assert.NotNull(image);

var base64 = image.ToBase64String(PngFormat.Instance);
_output.WriteLine(base64);
var expected = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAYAAAAZUZThAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA90lEQVR4nO3TS4rCQAAAUQPeO8zJ1SwEadKlWQwSeW+Ttn9Roa63h8vJLcvytz0fP2XdxttzXH/Ove4d18eze59n73m39zk/O3t077h/HM/ufV2bvW/v/5nNjd9zb++ZXS+/YZ2Mj66vk/lP7vnG3iNnZ2vv7v90bnbfqf1KIPAvBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQC4Q52RIKpZseR8gAAAABJRU5ErkJggg==";
Assert.Equal(expected, base64);
}


[Theory, ClassData(typeof(DataAlphanumeric))]
public void TestAlphanumericAll(Type _type, string _img64)
{
var barcode = new Barcode("HELLO!", _type, false, 200, 50);
var image = barcode.GetImage();

Assert.NotNull(image);

var base64 = image.ToBase64String(PngFormat.Instance);
_output.WriteLine(base64);
var expected = $"data:image/png;base64,{_img64}";
Assert.Equal(expected, base64);
}


[Theory, ClassData(typeof(DataNumeric))]
public void TestNumericAll(Type _type, string data, string _img64)
{
var barcode = new Barcode(data, _type, false, 200, 50);
var image = barcode.GetImage();

Assert.NotNull(image);

var base64 = image.ToBase64String(PngFormat.Instance);
_output.WriteLine(base64);
var expected = $"data:image/png;base64,{_img64}";
Assert.Equal(expected, base64);
}



}
public class DataAlphanumeric : IEnumerable<object[]>
{
private readonly List<object[]> _data = new List<object[]>
{
new object[] { Type.Code128, "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAYAAAAZUZThAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA90lEQVR4nO3TS4rCQAAAUQPeO8zJ1SwEadKlWQwSeW+Ttn9Roa63h8vJLcvytz0fP2XdxttzXH/Ove4d18eze59n73m39zk/O3t077h/HM/ufV2bvW/v/5nNjd9zb++ZXS+/YZ2Mj66vk/lP7vnG3iNnZ2vv7v90bnbfqf1KIPAvBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQC4Q52RIKpZseR8gAAAABJRU5ErkJggg==" },
new object[] { Type.Code128A, "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAYAAAAZUZThAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA90lEQVR4nO3TS4rCQAAAUQPeO8zJ1SwEadKlWQwSeW+Ttn9Roa63h8vJLcvytz0fP2XdxttzXH/Ove4d18eze59n73m39zk/O3t077h/HM/ufV2bvW/v/5nNjd9zb++ZXS+/YZ2Mj66vk/lP7vnG3iNnZ2vv7v90bnbfqf1KIPAvBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQC4Q52RIKpZseR8gAAAABJRU5ErkJggg==" },
new object[] { Type.Code128B, "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAYAAAAZUZThAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA90lEQVR4nO3TwYqDMAAA0Qr9b9kv360HYQnNVA+lWN67GNIkVXHuvw+3i1uW5We7Ph5l3cbbdZ/fx8/W/p8b9z7bP/ufI2v3+dnes2vH9eN4du74bsbz6p5e3cds7ZXdb99hPTA+MrdO5o+c/Ym1Z/bOfpt9yGff46vzLulbAoG3EAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIhD92RIKpQ/2KsAAAAABJRU5ErkJggg==" },
new object[] { Type.Code39E, "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAYAAAAZUZThAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA6klEQVR4nO3T0QqCQBQAUYX+W/ryyodAwqYsjIRzXtrW1ivGnC43wwGM43i+Peq0XM+f8/e1de0t7/Pumfve4/y95j078875tWesd/jqvW753Zb/ZziA03Ac08p6+uD6t2fW9vec98n5PebvMfvvHSkQ+DmBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUC4AhIyzxirHSbCAAAAAElFTkSuQmCC" }
};

public IEnumerator<object[]> GetEnumerator()
{ return _data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException();
}

public class DataNumeric : IEnumerable<object[]>
{
private readonly List<object[]> _data = new()
{
new object[] { Type.EAN8,"1234567", "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAYAAAAZUZThAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABAklEQVR4nO3TQW6DMBQA0SDlYOnJcrT2Zq3XEYxjFimL9ySEMA7+ijT33+H2z7Zt+xq3x7h+xjjfr897+2bvV9ePzj+67815dM7KeSvfrTnPzDf7v2bvZ/Mc/f7snJ9wv13DY1zPeN5bn71fXX9O1mf76pyV81a+W3Oeme/dfWfneXeu2fkfc5VA4JIEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBALhD3XrkiU5+0kOAAAAAElFTkSuQmCC" },
new object[] { Type.EAN13,"1234567890123", "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAYAAAAZUZThAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABEUlEQVR4nO3TXWqDQBhA0RGysHZlWVq7s9a+lZC5jsS8nQNBouPnD97bz2482Lbtc9987L/v/fDX4//Zumf7Z3Nm29XrrZw3u4+j5x0Tr76X1TnvuM648D2vPMd48bs4O+/K9/9/7W0897f4Hv/P7L8f7D9adzS3zpvdR80tNf/MvKM577jOle955T5f/S7OzlvZPzs+XT8LBBgCgSQQCAKBIBAIAoEgEAgCgSAQCAKBIBAIAoEgEAgCgSAQCAKBIBAIAoEgEAgCgSAQCAKBIBAIAoEgEAgCgSAQCAKBIBAIAoEgEAgCgSAQCAKBIBAIAoEgEAgCgSAQCAKBIBAIAoEgEAgCgSAQCAKBIBAIAoHwCxgmx5hQC0m8AAAAAElFTkSuQmCC" },
new object[] { Type.Code93, "1234567890123", "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAYAAAAZUZThAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABB0lEQVR4nO3T22qDQAAAUYX8t/TLm/RNRMdtE1MC57yseFl1dW7fD9NF5nn+eky/rMf18e2xn3F93dE82/11ztGx38w5un30zmfP9ez7jKzXu9d5/X2333rv3iNrV//PdJHbdK3lYKxz9s5bTvY/c4+ROUe39+Ydea6ad+R9Rtbrv9f57N571/9lDV/q6kDgowkEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBIJAIAgEgkAgCASCQCAIBMIdnnfukdjMDtoAAAAASUVORK5CYII=" },
new object[] { Type.Code39, "1234567890123", "iVBORw0KGgoAAAANSUhEUgAAAMgAAAAyCAYAAAAZUZThAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABEElEQVR4nO3T0WqDQBQA0Qj5b+mXtwk0kIZ11qWhUDjnRU1y1TXO9fPm8m3bto/b4f68f9/ej0f7R5+9zp+ZPTMz2j+aG20fv52t4Wg9o7nZes7MrDzz2bOu6x09s9k9jtbyH9+Dlff60cT18tM+2N/f9P1s9uzMyty71jCbm61n9d5+ez8r97b6n61c++w5/+o9WD7nayDAE4FAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQBAIBIFAEAgEgUAQCASBQPgCRxJWCWQeKtkAAAAASUVORK5CYII=" },
};

public IEnumerator<object[]> GetEnumerator()
{ return _data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException();
}
}
4 changes: 2 additions & 2 deletions NetBarcode.Tests/NetBarcode.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
2 changes: 1 addition & 1 deletion NetBarcode/NetBarcode.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<PackageProjectUrl>https://github.com/Tagliatti/NetBarcode</PackageProjectUrl>
<PackageTags>barcode</PackageTags>
<PackageIconUrl>https://i.imgur.com/BhcO3DF.jpg</PackageIconUrl>
Expand Down