コード例 #1
0
        public void ValidFromData()
        {
            var productCode = "12345678901234";
            var batchId     = "batchId";
            var expireDate  = new DateTime(2020, 5, 17);
            var code        = new LongProductCode(productCode, batchId, expireDate);

            Assert.AreEqual("(02)12345678901234(17)200517(10)batchId", code.Code);
        }
コード例 #2
0
        public void ValidFromString()
        {
            var codeString = "(02)12345678901234(17)200517(10)batchId";
            var code       = new LongProductCode(codeString);

            Assert.AreEqual("12345678901234", code.ProductCode);
            Assert.AreEqual("batchId", code.BatchId);
            Assert.AreEqual(new DateTime(2020, 5, 17), code.ExpireDate);
            Assert.AreEqual(codeString, code.Code);
        }
コード例 #3
0
 public ProductCodeData DecodeLongProductCode(string code)
 {
     if (LongProductCode.TryParse(code, out LongProductCode longProductCode))
     {
         return(new ProductCodeData
         {
             ProductCode = longProductCode.ProductCode,
             BatchId = longProductCode.BatchId,
             ExpireDate = longProductCode.ExpireDate
         });
     }
     return(null);
 }