Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
    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));
    }
Ejemplo n.º 3
0
    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);
    }