public void TestEPCConvertibility() { for (int index = 0; index < _NumTags; index++) { object tag = _Reader.SingulateTagAssisted(index); TagEPCURI_SGTIN epc = default(TagEPCURI_SGTIN); taginfo info = _TagInfos[index]; Console.WriteLine("Testing tag at position {0}", index); DecodeError res0 = default(DecodeError); res0 = _Reader.ReadEPC_SGTIN(tag, out epc); Assert.AreEqual(res0, DecodeError.None); Assert.AreEqual(epc.Identity.URI, info.PureIdentityURI); Assert.AreEqual(epc.Identity.GS1CompanyPrefixLength, info.GS1CompanyPrefixLength); Console.WriteLine("Trying to round-trip"); // Round-tripping should produce exactly the same data bool res1 = _Reader.WriteEPC(tag, epc); Assert.IsTrue(res1); TagEPCURI_SGTIN epc1 = default(TagEPCURI_SGTIN); res0 = _Reader.ReadEPC_SGTIN(tag, out epc1); Assert.AreEqual(res0, DecodeError.None); Assert.AreEqual(epc, epc1); } }
public void TestMCSUniqueness() { Dictionary <TagEPCURI_SGTIN, int> TIDmap = new Dictionary <TagEPCURI_SGTIN, int>(); for (int index = 0; index < _NumTags - 1; index++) { object tag = _Reader.SingulateTagAssisted(index); TagEPCURI_SGTIN epc = default(TagEPCURI_SGTIN); taginfo info = _TagInfos[index]; TID tid = default(TID); Console.WriteLine("Testing tag at position {0}", index); DecodeError res0 = default(DecodeError); res0 = _Reader.ReadTID(tag, out tid); Assert.AreEqual(res0, DecodeError.None); res0 = _Reader.ReadEPC_SGTIN(tag, out epc); Assert.AreEqual(res0, DecodeError.None); Console.WriteLine("Generating serial via MCS"); bool resB = false; TagEPCURI_SGTIN epc1 = default(TagEPCURI_SGTIN); resB = MCS.GenerateEPC(ref tid, ref epc, out epc1); Assert.AreEqual(resB, true); // there should not be any equal values Assert.AreEqual(false, TIDmap.ContainsKey(epc1)); TIDmap.Add(epc1, index); } }
public void TestMCS() { Console.WriteLine("Testing MCS"); for (int index = 0; index < _NumTags; index++) { object tag = _Reader.SingulateTagAssisted(index); TID tid = default(TID); TagEPCURI_SGTIN epc = default(TagEPCURI_SGTIN); taginfo info = _TagInfos[index]; Console.WriteLine("Testing tag at position {0}", index); DecodeError res = default(DecodeError); res = _Reader.ReadTID(tag, out tid); Assert.AreEqual(res, DecodeError.None); DecodeError res0 = _Reader.ReadEPC_SGTIN(tag, out epc); Assert.AreEqual(res0, DecodeError.None); Console.WriteLine("Generating a new EPC"); if ((tid.Serial != null) && tid.Serial.Length > 0) { TagEPCURI_SGTIN epc1 = default(TagEPCURI_SGTIN); var res1 = MCS.GenerateEPC(ref tid, ref epc, out epc1); Assert.IsTrue(res1); Console.WriteLine("New EPC SGTIN Pure Identity Tag URI {0}", epc1.Identity.URI); // Round-tripping should produce exactly the data that we want to see //res = _Reader.WriteEPC(tag, epc1) //Assert.IsTrue(res) //Dim epc1 As TagEPCURI_SGTIN //res = _Reader.ReadEPC(tag, epc1) //Assert.IsTrue(res) //Assert.AreEqual(epc, epc1) } else { Console.WriteLine("Skipping, because the TID does not provide a serial number"); } } }
public void TestEPCReading() { for (int index = 0; index < _NumTags; index++) { object tag = _Reader.SingulateTagAssisted(index); TID tid = default(TID); TagEPCURI_SGTIN epc = default(TagEPCURI_SGTIN); taginfo info = _TagInfos[index]; Console.WriteLine("Testing tag at position {0}", index); DecodeError res = default(DecodeError); res = _Reader.ReadTID(tag, out tid); Assert.AreEqual(res, DecodeError.None); if (!string.IsNullOrEmpty(info.STID_URI)) { Assert.AreEqual(tid.STID_URI, info.STID_URI); } if ((info.UTID != null) && info.UTID.Length > 0) { CollectionAssert.AreEqual(tid.Serial, info.UTID); } DecodeError res0 = default(DecodeError); res0 = _Reader.ReadEPC_SGTIN(tag, out epc); Assert.AreEqual(res0, DecodeError.None); Assert.AreEqual(epc.Identity.URI, info.PureIdentityURI); Console.WriteLine("Trying to round-trip"); // Round-tripping should produce exactly the same data bool res1 = _Reader.WriteEPC(tag, epc); Assert.IsTrue(res1); TagEPCURI_SGTIN epc1 = default(TagEPCURI_SGTIN); res0 = _Reader.ReadEPC_SGTIN(tag, out epc1); Assert.AreEqual(res0, DecodeError.None); Assert.AreEqual(epc, epc1); } }