示例#1
0
    protected void ExecuteTest(string modelAndBaseName)
    {
      // copy required input and assertion files
      DeploymentItem("ChanSort.Loader.LG\\ChanSort.Loader.LG.ini");
      DeploymentItem("Test.Loader.LG\\" + modelAndBaseName + ".TLL.in");
      DeploymentItem("Test.Loader.LG\\" + modelAndBaseName + ".csv.in");
      DeploymentItem("Test.Loader.LG\\" + modelAndBaseName + ".TLL.out");

      var baseName = Path.GetFileNameWithoutExtension(modelAndBaseName);

      // load the TLL file
      TllFileSerializerPlugin plugin = new TllFileSerializerPlugin();
      var serializer = (TllFileSerializer)plugin.CreateSerializer(baseName + ".TLL.in");
      serializer.IsTesting = true;
      serializer.Load();

      // verify channel name, number, favorites, ... against a reference list
      var data = serializer.DataRoot;
      data.ApplyCurrentProgramNumbers();
      AssertRefListContent(data, baseName + ".csv.in");

      // modify channel lists
      Editor editor = new Editor();
      editor.DataRoot = data;
      foreach (var list in data.ChannelLists)
      {
        var channels = this.Get2ndProgramNumber(list);
        if (channels != null)
        {
          editor.ChannelList = list;
          editor.MoveChannels(channels, true);
        }
      }

      // save TLL file and compate to reference file
      serializer.Save(tempFile);
      AssertBinaryFileContent(tempFile, baseName + ".TLL.out");
    }
示例#2
0
        private void LoadFiles(ISerializerPlugin plugin, string tvDataFile)
        {
            bool dataUpdated = false;
              try
              {
            if (DetectCommonFileCorruptions(tvDataFile))
              return;

            if (!this.LoadTvDataFile(plugin, tvDataFile))
              return;

            dataUpdated = true;
            this.gviewRight.BeginDataUpdate();
            this.gviewLeft.BeginDataUpdate();

            this.editor = new Editor();
            this.editor.DataRoot = this.dataRoot;

            this.currentChannelList = null;
            this.editor.ChannelList = null;
            this.gridRight.DataSource = null;
            this.gridLeft.DataSource = null;
            this.FillChannelListCombo();

            //this.SetControlsEnabled(!this.dataRoot.IsEmpty);
            this.UpdateFavoritesEditor(this.dataRoot.SupportedFavorites);

            if (this.dataRoot.Warnings.Length > 0 && this.miShowWarningsAfterLoad.Checked)
              this.BeginInvoke((Action)this.ShowFileInformation);

            this.BeginInvoke((Action)this.InitInitialChannelOrder);
              }
              catch (Exception ex)
              {
            if (!(ex is IOException))
              throw;
            string name = plugin != null ? plugin.PluginName : "Loader";
            XtraMessageBox.Show(this, name + "\n\n" + ex.Message, Resources.MainForm_LoadFiles_IOException,
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
            this.currentPlugin = null;
            this.currentTvFile = null;
            this.currentTvSerializer = null;
            this.Text = this.title;
              }
              finally
              {
            if (dataUpdated)
            {
              this.gviewRight.EndDataUpdate();
              this.gviewLeft.EndDataUpdate();
            }
              }
        }
示例#3
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)
      {
        CsvFileSerializer csv = new CsvFileSerializer(testDataDir + "\\" + basename + ".csv.in", tll.DataRoot, false);
        csv.Save();

        // 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");
    }