Example #1
0
        protected void GenerateTestFiles(string modelAndBaseName, bool moveChannels = true)
        {
            DeploymentItem("ChanSort.Loader.LG\\ChanSort.Loader.LG.ini");
            string solutionDir = this.GetSolutionBaseDir();
            var    testDataDir = solutionDir + "\\Test.Loader.LG\\" + Path.GetDirectoryName(modelAndBaseName);
            var    basename    = Path.GetFileNameWithoutExtension(modelAndBaseName);

            // copy .TLL.in
            string destFileName = testDataDir + "\\" + basename + ".TLL.in";

            if (!File.Exists(testDataDir + "\\" + basename + ".TLL.in"))
            {
                if (File.Exists(testDataDir + "\\" + basename + ".TLL.bak"))
                {
                    File.Move(testDataDir + "\\" + basename + ".TLL.bak", destFileName);
                }
                else
                {
                    File.Move(testDataDir + "\\" + basename + ".TLL", destFileName);
                }
            }

            // save .csv.in file (with ref list of original .TLL.in)
            TllFileSerializer tll = new TllFileSerializer(destFileName);

            tll.IsTesting = true;
            tll.Load();
            tll.DataRoot.ApplyCurrentProgramNumbers();
            if (moveChannels)
            {
                using (var writer = new StringWriter())
                {
                    CsvRefListSerializer.Save(writer, tll.DataRoot);
                    File.WriteAllText(testDataDir + "\\" + basename + ".csv.in", writer.ToString());
                }

                // save modified list as .TLL.out
                Console.WriteLine();
                Console.WriteLine(basename);
                Console.WriteLine("   a/c/t={0}, sat={1}", tll.ACTChannelLength, tll.SatChannelLength);
                Editor editor = new Editor();
                editor.DataRoot = tll.DataRoot;
                foreach (var list in tll.DataRoot.ChannelLists)
                {
                    editor.ChannelList = list;
                    var channels = this.Get2ndProgramNumber(list);
                    if (channels != null)
                    {
                        editor.MoveChannels(channels, true);
                        Console.WriteLine("   {0}={1}", list.ShortCaption, list.Count);
                    }
                }
            }
            else
            {
                tll.CleanUpChannelData();
            }
            tll.Save(testDataDir + "\\" + basename + ".TLL.out");
        }
Example #2
0
        private void AssertRefListContent(DataRoot dataRoot, string refListFile)
        {
            MemoryStream mem    = new MemoryStream();
            var          writer = new StreamWriter(mem);

            CsvRefListSerializer.Save(writer, dataRoot, false); // don't include deleted channels to maintain compatibility between new code and old test files
            writer.Flush();
            mem.Seek(0, SeekOrigin.Begin);
            var actual   = new StreamReader(mem).ReadToEnd();
            var expected = File.ReadAllText(refListFile);

            // satellite orbital position is no longer part of the UID (Samsung J series doesn't provide this information)
            var regex = new Regex(@",S\d+.\d+[EW](-\d+-\d+-\d+,)");

            expected = regex.Replace(expected, @",S$1");

            Assert.AreEqual(expected, actual);
        }