Esempio n. 1
0
        public void VariableLengthMissingFnc1_InvalidTokenException()
        {
            const string data   = "21123451116050517200505";
            var          parser = new Gs1128Parser(data);

            Assert.Throws <InvalidTokenException>(() => parser.Parse());
        }
Esempio n. 2
0
        public void Parse_Gs1_128_Multiple_Fnc1()
        {
            var data    = $"2112345{Gs1128Parser.Fnc1}1116050517200505";
            var parser  = new Gs1128Parser(data);
            var barcode = parser.Parse();

            Assert.Equal(3, barcode.Count);
        }
Esempio n. 3
0
        public void Parse_Gs1_128_Multiple_Compact()
        {
            const string data    = "11160505172005052112345";
            var          parser  = new Gs1128Parser(data);
            var          barcode = parser.Parse();

            Assert.Equal(3, barcode.Count);
        }
Esempio n. 4
0
        public void Parse_Gs1_128_ApplicationIdentifierVariable()
        {
            const double weight  = 0.480d;
            var          data    = $"{ApplicationIdentifierManager.Gtin}00238806011234{ApplicationIdentifierManager.ProductionNetWeight}3000480";
            var          parser  = new Gs1128Parser(data);
            var          barcode = parser.Parse();
            var          ai      = (ApplicationIdentifier)barcode[ApplicationIdentifierManager.ProductionNetWeight];

            Assert.Equal(weight, ai.Parse());
        }
Esempio n. 5
0
        public void Parse_Gs1_128_Sssc18()
        {
            const string sscc    = "123456789101112131";
            var          data    = $"{ApplicationIdentifierManager.Sscc}{sscc}";
            var          parser  = new Gs1128Parser(data);
            var          barcode = parser.Parse();

            Assert.NotNull(barcode);
            Assert.Equal(1, barcode.Count);
            var ai = (ApplicationIdentifier)barcode[ApplicationIdentifierManager.Sscc];

            Assert.Equal(ApplicationIdentifierManager.Sscc, ai.Identifier);
            Assert.Equal(sscc, ai.Parse());
        }
Esempio n. 6
0
        public void AddCompanyInternalApplicationIdentifier()
        {
            const ushort company = 91;

            ApplicationIdentifierManager.AddApplicationIdentifier(company, () => new CompanyApplicationIdentifierMock("91", "Company internal 91", 1, 30));
            const string data    = "91MyCustomData";
            var          parser  = new Gs1128Parser(data);
            var          barcode = parser.Parse();

            Assert.Equal(1, barcode.Count);
            Assert.IsType <CompanyApplicationIdentifierMock>(barcode["91"]);
            var ai = (CompanyApplicationIdentifierMock)barcode["91"];

            Assert.Equal("91", ai.Identifier);
            Assert.Equal("MyCustomData", ai.Parse());
        }
Esempio n. 7
0
        public void Parse_Gs1_128_Multiple_Sscc18_ProductionDate()
        {
            const string productionDate = "160505";
            const string sscc           = "123456789101112131";
            var          data           = $"{ApplicationIdentifierManager.Sscc}{sscc}{ApplicationIdentifierManager.ProductionDate}{productionDate}";
            var          parser         = new Gs1128Parser(data);
            var          barcode        = parser.Parse();

            Assert.NotNull(barcode);
            Assert.Equal(2, barcode.Count);
            var ai = (ApplicationIdentifier)barcode[ApplicationIdentifierManager.Sscc];

            Assert.Equal(ApplicationIdentifierManager.Sscc, ai.Identifier);
            Assert.Equal(sscc, ai.Parse());

            ai = (ApplicationIdentifier)barcode[ApplicationIdentifierManager.ProductionDate];
            Assert.Equal(ApplicationIdentifierManager.ProductionDate, ai.Identifier);
            Assert.Equal(new DateTime(2016, 5, 5).Date, ai.Parse());
        }