public void InvalidNumberOfDigits() { var codeToValidate = "978902841424"; var success = Ean13.TryParse(codeToValidate, out _); success.Should().Be(Ean13.ResultCode.InvalidNumberOfDigits); }
private void CreateEan13(string codigoOperacion) { ean13 = new Ean13(); ean13.CountryCode = codigoOperacion.PadLeft(6, '0'); ean13.ManufacturerCode = codigoOperacion.PadLeft(6, '0'); ean13.ProductCode = ""; }
public void CreateEan13() { var eanWithoutChecksum = 020067170423; var result = Ean13.Create(eanWithoutChecksum, out var ean13); Console.WriteLine($"Result is: {result}, Code: {ean13} Checksum: {ean13.Checksum}"); }
public void Ean13ConstructorTest() { int[] ean13 = null; // TODO: initialisez à une valeur appropriée Ean13 target = new Ean13(ean13); Assert.Inconclusive("TODO: implémentez le code pour vérifier la cible"); }
public void AsReadOnlyCharSpan_NoExceptions_Test(long digits) { //Arrange Ean13.Create(digits, out var ean13); //Act & Assert new string(ean13.AsReadOnlyCharSpan()).Should().Be(ean13.ToString()); }
public void Ean13ConstructorTest() { try { Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 8, 0 }); } catch (Exception e) { Assert.AreEqual(e.Message, "Un code Ean 13 doit être un tableau de 12 entiers"); } try { Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8 }); } catch (Exception e) { Assert.AreEqual(e.Message, "Un code Ean 13 doit être un tableau de 12 entiers"); return; } try { Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 25 }); } catch (Exception e) { Assert.AreEqual(e.Message, "Un élément du gencode n'est pas compris entre 0 et 9"); return; } Assert.Fail("Aucune exeption n'a été soulevée"); }
public void CreateTest(long digits, Ean13.ResultCode expectedResultCode, long expected) { var resultCode = Ean13.Create(digits, out var ean13); resultCode.Should().Be(expectedResultCode); ean13.Ean13Code.Should().Be(expected); }
public void ChecksumFailed() { var codeToValidate = "9789028414245"; var success = Ean13.TryParse(codeToValidate, out _); success.Should().Be(Ean13.ResultCode.InvalidChecksum); }
public Etiqueta(string produto) { InitializeComponent(); try { this.etiquetas.LocalReport.EnableExternalImages = true; MySqlDataAdapter da; bdProdutos bdProduto = new bdProdutos(); mConn = new MySqlConnection(connString); mConn.Open(); string sql = $"SELECT * from Produto where " + produto; MySqlCommand cmd = new MySqlCommand(sql, mConn); da = new MySqlDataAdapter(cmd); da.Fill(bdProduto, bdProduto.Tables[0].TableName); ReportDataSource rds = new ReportDataSource("Produtos", bdProduto.Tables[0]); this.etiquetas.LocalReport.DataSources.Clear(); this.etiquetas.LocalReport.DataSources.Add(rds); this.etiquetas.LocalReport.Refresh(); this.etiquetas.SetDisplayMode(DisplayMode.PrintLayout); var setup = etiquetas.GetPageSettings(); setup.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0); etiquetas.SetPageSettings(setup); this.etiquetas.RefreshReport(); MySqlDataReader leitor = cmd.ExecuteReader(); string codBarra = ""; while (leitor.Read()) { codBarra = leitor["codBarra"].ToString(); } ean13 = new Ean13(); ean13.CountryCode = codBarra; ean13.Scale = (float)Convert.ToDecimal(0.5); System.Drawing.Bitmap bmp = ean13.CreateBitmap(); bmp.Save(Application.StartupPath + "\\img.jpg"); this.etiquetas.LocalReport.EnableExternalImages = true; this.etiquetas.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("Etiqueta", @"File://" + Application.StartupPath + "\\img.jpg")); this.etiquetas.LocalReport.DataSources.Clear(); this.etiquetas.LocalReport.DataSources.Add(rds); this.etiquetas.RefreshReport(); } finally { mConn.Close(); } }
private void CreateEan13() { ean13 = new Ean13(); ean13.CountryCode = "00"; ean13.ManufacturerCode = "00000"; ean13.ProductCode = Convert.ToString(aparelho_OS.getID()); ean13.ChecksumDigit = "0"; }
public void PoidsImpairTest() { Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 8 }); int expected = 20; int actual = target.PoidsImpair(); Assert.AreEqual(expected, actual); }
public void CleTest() { Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 8 }); int expected = 9; int actual = target.Cle(); Assert.AreEqual(expected, actual); }
public void ToStringTest() { Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 8 }); string expected = "4719-5120-0288-9"; string actual = target.ToString(); Assert.AreEqual(expected, actual); }
public void ToStringTest() { Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 8 }); // TODO: initialisez à une valeur appropriée string expected = "4719-5120-0288-9"; // TODO: initialisez à une valeur appropriée string actual; actual = target.ToString(); Assert.AreEqual(expected, actual); }
public void PoidsPairTest() { //int[] ean13 = null; // TODO: initialisez à une valeur appropriée Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 8 }); // TODO: initialisez à une valeur appropriée int expected = 81; // TODO: initialisez à une valeur appropriée int actual = target.PoidsPair(); Assert.AreEqual(expected, actual); }
public void CheckSumMatches(string codeToValidate, int expectedCheckSum) { //Act var success = Ean13.TryParse(codeToValidate, out var ean13); //Assert success.Should().Be(Ean13.ResultCode.Success); ean13.Checksum.Should().Be(expectedCheckSum); }
public void Ok(string codeToValidate, long expected) { //Act var success = Ean13.TryParse(codeToValidate, out var ean13); //Assert success.Should().Be(Ean13.ResultCode.Success); ean13.Ean13Code.Should().Be(expected); }
public void PoidsImpairTest() { Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 8 }); int expected = 20; // TODO: initialisez à une valeur appropriée int actual; actual = target.PoidsImpair(); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Vérifiez l\'exactitude de cette méthode de test."); }
public void ToStringTest() { Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 8 }); // TODO: initialisez à une valeur appropriée string expected = "4719-5120-0288-9"; // TODO: initialisez à une valeur appropriée string actual; actual = target.ToString(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Vérifiez l\'exactitude de cette méthode de test."); }
public void MetaDataToStringSmokeTest() { //Arrange Ean13.TryParse("9789490433024", out var ean13); ISBN13.TryParse(_ruleTrees, ean13, out var metadataOpt).Should().BeTrue(); //Act var formattedString = metadataOpt.Match(() => "", metadata => metadata.ToString()); //Assert formattedString.Should().Be("978-94-90433-02-4"); }
public void AsReadOnlyCharSpanTests(long digitsWithoutChecksum, string expectedStr) { //Arrange Ean13.Create(digitsWithoutChecksum, out var ean13).Should().Be(Ean13.ResultCode.Success); //Act var asSpan = ean13.AsReadOnlyCharSpan(); //Assert new string(asSpan).Should().Be(expectedStr); }
public void resteTest() { int[] ean13 = { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 8 }; // TODO: initialisez à une valeur appropriée Ean13 target = new Ean13(ean13); // TODO: initialisez à une valeur appropriée int expected = 1; // TODO: initialisez à une valeur appropriée int actual; actual = target.reste(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Vérifiez l\'exactitude de cette méthode de test."); }
public void CleTest() { //int[] ean13 = null; // TODO: initialisez à une valeur appropriée Ean13 target = new Ean13(new int[] { 4, 7, 1, 9, 5, 1, 2, 0, 0, 2, 8, 8 }); // TODO: initialisez à une valeur appropriée int expected = 9; // TODO: initialisez à une valeur appropriée int actual; actual = target.Cle(); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Vérifiez l\'exactitude de cette méthode de test."); }
public ActionResult Barcode(string code) { var ean13 = new Ean13(code); Bitmap bmp = ean13.CreateBitmap(); MemoryStream stream = new MemoryStream(); bmp.Save(stream, ImageFormat.Png); return(File(stream.ToArray(), "image/png")); }
public void PoidsPairTest() { int[] ean13 = null; // TODO: initialisez à une valeur appropriée Ean13 target = new Ean13(ean13); // TODO: initialisez à une valeur appropriée int expected = 0; // TODO: initialisez à une valeur appropriée int actual; actual = target.PoidsPair(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Vérifiez l\'exactitude de cette méthode de test."); }
public void ToStringTest() { int[] ean13 = null; // TODO: initialisez à une valeur appropriée Ean13 target = new Ean13(ean13); // TODO: initialisez à une valeur appropriée string expected = string.Empty; // TODO: initialisez à une valeur appropriée string actual; actual = target.ToString(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Vérifiez l\'exactitude de cette méthode de test."); }
public void CanCalculateCheckDigit() { int check = Ean13.CalculateCheckDigit("890400021003"); Assert.AreEqual(7, check); check = Ean13.CalculateCheckDigit("201000450000"); Assert.AreEqual(8, check); check = Ean13.CalculateCheckDigit("978020113447"); Assert.AreEqual(6, check); }
private void button1_Click(object sender, EventArgs e) { Ean13 barcode = new Ean13(); barcode.CountryCode = "90"; barcode.ManufacturerCode = r.Next(10000, 99999).ToString(); Random r2 = new Random(); barcode.ProductCode = r2.Next(10000, 99999).ToString(); barcode.ChecksumDigit = r2.Next(1, 10).ToString(); pictureBox1.Image = barcode.CreateBitmap(); }
private void prntDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.PageUnit = GraphicsUnit.Millimeter; Ean13 barcode = new Ean13(); int adet = Convert.ToInt32(nmBarkodAdet.Value); int xx = (int)bA_SolKenarBosluk.Value; int yy = (int)bA_ustKenarBosluk.Value; int satir = 1; for (int i = 1; i <= bA_satirAdet.Value * bA_sutunAdet.Value; i++) { if (_yazilan >= adet || satir > bA_satirAdet.Value) { return; } else { _sonBarkod++; } barcode.ChecksumDigit = "0"; if (_barkodlar == null || _barkodlar.Length == 0) { barcode.CountryCode = "000"; barcode.ManufacturerCode = "0000"; barcode.ProductCode = _sonBarkod.ToString().PadLeft(5, '0'); } else { barcode.CountryCode = _barkodlar[i - 1].Substring(0, 3); barcode.ManufacturerCode = _barkodlar[i - 1].Substring(3, 4); barcode.ProductCode = _barkodlar[i - 1].Substring(7, 5); } barcode.Scale = (float)(bA_olcek.Value * 0.01m); barcode.Width = (float)bA_etiketGenislik.Value; barcode.Height = (float)bA_etiketYukseklik.Value; barcode.DrawEan13Barcode(e.Graphics, new PointF(xx, yy)); xx += (int)bA_sutunBosluk.Value + (int)bA_etiketGenislik.Value; if (i % (int)bA_sutunAdet.Value == 0) { xx = (int)bA_SolKenarBosluk.Value; yy += (int)bA_etiketYukseklik.Value + (int)bA_satirBosluk.Value; satir++; } _yazilan++; } e.HasMorePages = _yazilan < adet; }
private bool InputIsInvalid(string input) { if (input.Length > Ean13.CheckedLength) { return(true); } if (input.Length == Ean13.CheckedLength && !Ean13.Check(input)) { return(true); } return(input.ToCharArray().Any(_ => !char.IsDigit(_))); }