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 Setup() { var assembly = typeof(DataTest).GetTypeInfo().Assembly; string AssemblyName = assembly.GetName().Name; string Tags = null; using (StreamReader sr = new StreamReader(assembly.GetManifestResourceStream(AssemblyName + ".TagPopulation.csv"))) { Tags = sr.ReadToEnd(); } List <string> LinesLst = new List <string>(); foreach (string Ln in MockReaderLowLevel.SplitToLines(Tags)) { LinesLst.Add(Ln); } // Remove the first line (header line) string[] Lines = LinesLst.Skip(1).ToArray(); // Record how many tags we have _NumTags = Lines.Length; _TagInfos = new taginfo[_NumTags + 1]; int I = 0; foreach (string line in Lines) { if (string.IsNullOrEmpty(line)) { break; } taginfo info = new taginfo(); string[] cells = line.Split(';'); if (cells.Length < 5) { break; } if (System.Text.RegularExpressions.Regex.IsMatch(cells[3], "^([0-9a-fA-F]-?)+$")) { string hex = cells[3]; info.UTID = Utility.HexStringToByteArray(hex); } else if (!string.IsNullOrEmpty(cells[3])) { info.STID_URI = cells[3]; } info.PureIdentityURI = cells[4]; _TagInfos[I] = info; I = I + 1; } // pass down to the mock reader _Reader = new MockReaderLowLevel(Lines); }
public void Setup() { var assembly = typeof(ConvertibilityTest).GetTypeInfo().Assembly; string AssemblyName = assembly.GetName().Name; string Tags = null; using (StreamReader sr = new StreamReader(assembly.GetManifestResourceStream(AssemblyName + ".TagPopulationConvertibility.csv"))) { Tags = sr.ReadToEnd(); } List <string> LinesLst = new List <string>(); foreach (string Ln in MockReaderLowLevel.SplitToLines(Tags)) { LinesLst.Add(Ln); } // Remove the first line (header line) string[] Lines = LinesLst.Skip(1).ToArray(); // Record how many tags we have _NumTags = Lines.Length; _TagInfos = new List <taginfo>(); int I = 0; foreach (string line in Lines) { if (string.IsNullOrEmpty(line)) { break; } taginfo info = new taginfo(); string[] cells = line.Split(';'); if (cells.Length != 4) { break; } info.PureIdentityURI = cells[0]; info.GS1CompanyPrefixLength = Convert.ToInt32(cells[1]); info.TagURI = cells[2]; // add the missing memory chunk info.EPCbank = InterrogatorLib.Utility.HexStringToByteArray("C41E3400" + cells[3]); _TagInfos.Add(info); I = I + 1; } // pass down to the mock reader _Reader = new MockReaderLowLevel(_TagInfos.Select(ti => ti.EPCbank)); }
public void Setup() { var assembly = typeof(MCSUniquenessTest).GetTypeInfo().Assembly; string AssemblyName = assembly.GetName().Name; string Tags = null; using (StreamReader sr = new StreamReader(assembly.GetManifestResourceStream(AssemblyName + ".TagPopulationMCSUniqueness.csv"))) { Tags = sr.ReadToEnd(); } List <string> LinesLst = new List <string>(); foreach (string Ln in MockReaderLowLevel.SplitToLines(Tags)) { LinesLst.Add(Ln); } // Remove the first line (header line) string[] Lines = LinesLst.Skip(1).ToArray(); // Record how many tags we have _NumTags = Lines.Length; _TagInfos = new List <taginfo>(); int I = 0; foreach (string line in Lines) { if (string.IsNullOrEmpty(line)) { break; } taginfo info = new taginfo(); string[] cells = line.Split(';'); if (cells.Length < 2) { break; } info.TID = InterrogatorLib.Utility.HexStringToByteArray(cells[0]); info.EPC = InterrogatorLib.Utility.HexStringToByteArray(cells[1]); _TagInfos.Add(info); I = I + 1; } // pass down to the mock reader _Reader = new MockReaderLowLevel(Lines); }
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); } }
public void TestRawTagURIReading() { StringBuilder sb = new StringBuilder(); for (int index = 0; index < _NumTags; index++) { object tag = _Reader.SingulateTagAssisted(index); TagRaw raw = default(TagRaw); taginfo info = _TagInfos[index]; Console.WriteLine("Testing tag at position {0}", index); DecodeError res = default(DecodeError); res = _Reader.ReadEPC_Raw(tag, out raw); Assert.AreEqual(res, DecodeError.None); sb.Length = 0; raw.GetURI(sb); string uri = sb.ToString(); Assert.AreEqual(uri, info.RawURI); // TODO: write the encoding code, and test that it works } }