mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-01-23 23:59:03 +01:00
- renamed loaders
- added experimental support for Panasonic - fixed Encrypted-flag detection for Samsung Analog and DVB-C/T channels - text editors now only open after holding the mouse button for 0.5sec - new menu item/button for deleting channels from the right list
This commit is contained in:
141
Test.Loader.TllFile/LgTest.cs
Normal file
141
Test.Loader.TllFile/LgTest.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using ChanSort.Loader.LG;
|
||||
|
||||
namespace Test.Loader
|
||||
{
|
||||
[TestClass]
|
||||
public class LgTest : LoaderTestBase
|
||||
{
|
||||
#region TestLgTllLoader()
|
||||
[TestMethod]
|
||||
[DeploymentItem("ChanSort.Loader.LG\\ChanSort.Loader.LG.ini")]
|
||||
public void TestLgTllLoader()
|
||||
{
|
||||
var expectedData = this.InitExpectedLgData();
|
||||
TllFileSerializerPlugin plugin = new TllFileSerializerPlugin();
|
||||
|
||||
StringBuilder errors = new StringBuilder();
|
||||
var list = this.FindAllFiles("TestFiles", "*.tll");
|
||||
var models = new Dictionary<string,string>();
|
||||
var firmwareSize = new Dictionary<int, string>();
|
||||
foreach(var file in list)
|
||||
{
|
||||
if (file.Contains("GlobalClone") || file.Contains("CountrySettings"))
|
||||
continue;
|
||||
Debug.Print("Testing " + file);
|
||||
try
|
||||
{
|
||||
var serializer = plugin.CreateSerializer(file) as TllFileSerializer;
|
||||
Assert.IsNotNull(serializer, "No Serializer for " + file);
|
||||
|
||||
serializer.Load();
|
||||
|
||||
var fileName = Path.GetFileName(file) ?? "";
|
||||
int idx = fileName.IndexOf("-");
|
||||
string key = idx < 0 ? fileName : fileName.Substring(0, idx);
|
||||
var satChannelList = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.DvbS|ChanSort.Api.SignalSource.Tv);
|
||||
key += "\t" + serializer.ACTChannelLength+
|
||||
"\t"+serializer.HasDvbs+
|
||||
"\t"+serializer.SatChannelLength+
|
||||
"\t" + (satChannelList == null ? "n/a" : satChannelList.Count.ToString());
|
||||
string relPath = Path.GetFileName(Path.GetDirectoryName(file))+"\\"+fileName;
|
||||
models[key] = relPath;
|
||||
|
||||
var model = this.GetLgModel(file);
|
||||
if (firmwareSize.ContainsKey(serializer.FirmwareBlockSize))
|
||||
{
|
||||
string x = firmwareSize[serializer.FirmwareBlockSize];
|
||||
if (!x.Contains(model))
|
||||
firmwareSize[serializer.FirmwareBlockSize] = x + ", " + model;
|
||||
}
|
||||
else
|
||||
firmwareSize[serializer.FirmwareBlockSize] = model;
|
||||
|
||||
|
||||
|
||||
Assert.IsFalse(serializer.DataRoot.IsEmpty, "No channels loaded from " + file);
|
||||
|
||||
ExpectedData exp;
|
||||
key = Path.GetFileName(Path.GetDirectoryName(file)) + "\\" + Path.GetFileName(file);
|
||||
if (expectedData.TryGetValue(key, out exp))
|
||||
{
|
||||
var analogTv = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.AnalogCT|ChanSort.Api.SignalSource.Tv);
|
||||
var dtvTv = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.DvbCT|ChanSort.Api.SignalSource.Tv);
|
||||
var satTv = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.DvbS | ChanSort.Api.SignalSource.Tv);
|
||||
expectedData.Remove(key);
|
||||
Assert.AreEqual(exp.AnalogChannels, analogTv.Channels.Count, file + ": analog");
|
||||
Assert.AreEqual(exp.DtvChannels, dtvTv.Channels.Count, file + ": DTV");
|
||||
if (exp.SatChannels != 0)
|
||||
Assert.AreEqual(exp.SatChannels, satTv.Channels.Count, file + ": Sat");
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
errors.AppendLine();
|
||||
errors.AppendLine();
|
||||
errors.AppendLine(file);
|
||||
errors.AppendLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var model in models.OrderBy(e => e.Key))
|
||||
Debug.WriteLine(model.Key + "\t"+model.Value);
|
||||
|
||||
foreach (var size in firmwareSize.OrderBy(e => e.Key))
|
||||
Debug.WriteLine(size.Key + "\t" + size.Value);
|
||||
|
||||
if (expectedData.Count > 0)
|
||||
Assert.Fail("Some files were not tested: " + expectedData.Keys.Aggregate((prev,cur) => prev+","+cur));
|
||||
Assert.AreEqual("", errors.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region InitExpectedLgData()
|
||||
private Dictionary<string,ExpectedData> InitExpectedLgData()
|
||||
{
|
||||
var expected = new[]
|
||||
{
|
||||
new ExpectedData(@"opel\xx2350D-PZM00001.TLL", 31, 345, 0, 89, 0), // 164/-
|
||||
new ExpectedData(@"defycgn\xxLH4010-ZD99970.TLL", 34, 280, 0, 129, 0), // 164/-
|
||||
new ExpectedData(@"karlv\xxLD750-ZA00001.TLL", 30, 248, 0, 104, 0), // 176/-
|
||||
new ExpectedData(@"JLevi\xxLE5500-ZA00002.TLL", 36, 0, 0, 0, 0), // 176/-
|
||||
new ExpectedData(@"chlabnet\xxLK450-ZB00001.TLL", 34, 310, 0, 128, 0), // 176/-
|
||||
new ExpectedData(@"Stabilo\xxLW4500-ZB00001.TLL", 31, 338, 0, 34, 0), // 176/-
|
||||
new ExpectedData(@"MarioAntonioLiptaj\xxPT353-ZA00001.TLL", 50, 123, 0, 13, 0), // 180/-
|
||||
new ExpectedData(@"Muffix\xxLW5500-ZE00001.TLL", 34, 290, 0, 125, 0), // 184/-
|
||||
new ExpectedData(@"FranzSteinert\xxCS460S-ZA00001.TLL", 0, 0, 1261, 0, 200), // ?/68
|
||||
new ExpectedData(@"Klausi1\xxLK950S-ZA00001.TLL", 37, 390, 2695, 150, 491), // 184/68
|
||||
new ExpectedData(@"MP3Chris2712\xxLV570S-ZB00001.TLL", 0, 12, 2895, 0, 669), // 184/68
|
||||
new ExpectedData(@"decklen\xxLW570S-ZD00001.TLL", 0, 30, 1598, 0, 339), // 184/68
|
||||
new ExpectedData(@"NeuerScan\xxLM340S-ZA00001.TLL", 34, 317, 1698, 129, 264), // 188/68
|
||||
new ExpectedData(@"wagnale\xxLM611S-ZA00001.TLL", 0, 13, 1094, 0, 191), // 188/68
|
||||
new ExpectedData(@"_Pred\xxLM620S-ZE00021.TLL", 0, 11, 1303, 0, 191) // 192/72
|
||||
};
|
||||
|
||||
var dict = new Dictionary<string, ExpectedData>(StringComparer.InvariantCultureIgnoreCase);
|
||||
foreach (var entry in expected)
|
||||
dict[entry.File] = entry;
|
||||
return dict;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private string GetLgModel(string filePath)
|
||||
{
|
||||
string name = Path.GetFileName(filePath)??"";
|
||||
if (name.StartsWith("xx"))
|
||||
{
|
||||
int idx = name.IndexOf("-");
|
||||
if (idx > 0)
|
||||
return name.Substring(2, idx - 2);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
62
Test.Loader.TllFile/LoaderTestBase.cs
Normal file
62
Test.Loader.TllFile/LoaderTestBase.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Test.Loader
|
||||
{
|
||||
public class LoaderTestBase
|
||||
{
|
||||
#region class ExpectedData
|
||||
public class ExpectedData
|
||||
{
|
||||
public readonly string File;
|
||||
public readonly int AnalogChannels;
|
||||
public readonly int DtvChannels;
|
||||
public readonly int SatChannels;
|
||||
public readonly int DtvRadio;
|
||||
public readonly int SatRadio;
|
||||
|
||||
public ExpectedData(string file, int analog, int dtv, int sat, int dtvRadio, int satRadio)
|
||||
{
|
||||
this.File = file;
|
||||
this.AnalogChannels = analog;
|
||||
this.DtvChannels = dtv;
|
||||
this.SatChannels = sat;
|
||||
this.DtvRadio = dtvRadio;
|
||||
this.SatRadio = satRadio;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
protected IEnumerable<string> FindAllFiles(string baseDir, string mask)
|
||||
{
|
||||
string path = this.GetTestFileDirectory(baseDir);
|
||||
List<string> files = new List<string>();
|
||||
this.FindAllTllFilesRecursively(path, mask, files);
|
||||
return files;
|
||||
}
|
||||
|
||||
private string GetTestFileDirectory(string baseDir)
|
||||
{
|
||||
string exeDir = Assembly.GetExecutingAssembly().Location;
|
||||
while (!string.IsNullOrEmpty(exeDir))
|
||||
{
|
||||
string testFileDir = Path.Combine(exeDir, baseDir);
|
||||
if (Directory.Exists(testFileDir))
|
||||
return testFileDir;
|
||||
exeDir = Path.GetDirectoryName(exeDir);
|
||||
}
|
||||
throw new FileNotFoundException("No 'TestFiles' directory found");
|
||||
}
|
||||
|
||||
private void FindAllTllFilesRecursively(string path, string mask, List<string> files)
|
||||
{
|
||||
files.AddRange(Directory.GetFiles(path, mask));
|
||||
foreach (var dir in Directory.GetDirectories(path))
|
||||
this.FindAllTllFilesRecursively(dir, mask, files);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
96
Test.Loader.TllFile/SamsungTest.cs
Normal file
96
Test.Loader.TllFile/SamsungTest.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using ChanSort.Loader.Samsung;
|
||||
|
||||
namespace Test.Loader
|
||||
{
|
||||
[TestClass]
|
||||
public class SamsungTest : LoaderTestBase
|
||||
{
|
||||
#region InitExpectedSamsungData()
|
||||
private Dictionary<string, ExpectedData> InitExpectedSamsungData()
|
||||
{
|
||||
var expected = new[]
|
||||
{
|
||||
new ExpectedData(@"catmater_B\Clone.scm", 31, 272, 0, 0, 0) ,
|
||||
new ExpectedData(@"easy2003_B\easy2003_B.scm", 0, 0, 1225, 0, 0) ,
|
||||
new ExpectedData(@"_Manu_C\channel_list_LE40C650_1001.scm", 0, 9, 0, 0, 0)
|
||||
};
|
||||
|
||||
var dict = new Dictionary<string, ExpectedData>(StringComparer.InvariantCultureIgnoreCase);
|
||||
foreach (var entry in expected)
|
||||
dict[entry.File] = entry;
|
||||
return dict;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TestSamsungScmLoader()
|
||||
[TestMethod]
|
||||
[DeploymentItem("ChanSort.Loader.Samsung\\ChanSort.Loader.Samsung.ini")]
|
||||
public void TestSamsungScmLoader()
|
||||
{
|
||||
var expectedData = this.InitExpectedSamsungData();
|
||||
ScmSerializerPlugin plugin = new ScmSerializerPlugin();
|
||||
|
||||
StringBuilder errors = new StringBuilder();
|
||||
var list = this.FindAllFiles("TestFiles_Samsung", "*.scm");
|
||||
var models = new Dictionary<string, string>();
|
||||
foreach (var file in list)
|
||||
{
|
||||
Debug.Print("Testing " + file);
|
||||
try
|
||||
{
|
||||
var serializer = plugin.CreateSerializer(file) as ScmSerializer;
|
||||
Assert.IsNotNull(serializer, "No Serializer for " + file);
|
||||
|
||||
serializer.Load();
|
||||
|
||||
var fileName = Path.GetFileName(file) ?? "";
|
||||
string key = fileName.StartsWith("channel_list_") ? fileName.Substring(13, fileName.IndexOf('_',14)-13) : fileName;
|
||||
|
||||
string relPath = Path.GetFileName(Path.GetDirectoryName(file)) + "\\" + fileName;
|
||||
models[key] = relPath;
|
||||
|
||||
Assert.IsFalse(serializer.DataRoot.IsEmpty, "No channels loaded from " + file);
|
||||
|
||||
ExpectedData exp;
|
||||
key = Path.GetFileName(Path.GetDirectoryName(file)) + "\\" + Path.GetFileName(file);
|
||||
if (expectedData.TryGetValue(key, out exp))
|
||||
{
|
||||
var analogTv = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.AnalogC | ChanSort.Api.SignalSource.TvAndRadio);
|
||||
var dtvTv = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.DvbCT | ChanSort.Api.SignalSource.TvAndRadio);
|
||||
var satTv = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.DvbS | ChanSort.Api.SignalSource.TvAndRadio);
|
||||
expectedData.Remove(key);
|
||||
if (exp.AnalogChannels != 0 || analogTv != null)
|
||||
Assert.AreEqual(exp.AnalogChannels, analogTv.Channels.Count, file + ": analog");
|
||||
if (exp.DtvChannels != 0 || dtvTv != null)
|
||||
Assert.AreEqual(exp.DtvChannels, dtvTv.Channels.Count, file + ": DTV");
|
||||
if (exp.SatChannels != 0 || satTv != null)
|
||||
Assert.AreEqual(exp.SatChannels, satTv.Channels.Count, file + ": Sat");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errors.AppendLine();
|
||||
errors.AppendLine();
|
||||
errors.AppendLine(file);
|
||||
errors.AppendLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var model in models.OrderBy(e => e.Key))
|
||||
Debug.WriteLine(model.Key + "\t" + model.Value);
|
||||
|
||||
if (expectedData.Count > 0)
|
||||
Assert.Fail("Some files were not tested: " + expectedData.Keys.Aggregate((prev, cur) => prev + "," + cur));
|
||||
Assert.AreEqual("", errors.ToString());
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@
|
||||
<ProjectGuid>{68CFCB2F-B52A-43A1-AA5C-5D64A1D655D2}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Test.Loader.TllFile</RootNamespace>
|
||||
<AssemblyName>Test.Loader.TllFile</AssemblyName>
|
||||
<RootNamespace>Test.Loader</RootNamespace>
|
||||
<AssemblyName>Test.Loader</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
@@ -67,8 +67,10 @@
|
||||
</CodeAnalysisDependentAssemblyPaths>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LgTest.cs" />
|
||||
<Compile Include="LoaderTestBase.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UnitTest1.cs" />
|
||||
<Compile Include="SamsungTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ChanSort.Api\ChanSort.Api.csproj">
|
||||
@@ -76,9 +78,21 @@
|
||||
<Name>ChanSort.Api</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ChanSort.Loader.TllFile\ChanSort.Loader.TllFile.csproj">
|
||||
<ProjectReference Include="..\ChanSort.Loader.DbFile\ChanSort.Loader.Toshiba.csproj">
|
||||
<Project>{F6F02792-07F1-48D5-9AF3-F945CA5E3931}</Project>
|
||||
<Name>ChanSort.Loader.Toshiba</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ChanSort.Loader.Panasonic\ChanSort.Loader.Panasonic.csproj">
|
||||
<Project>{68DA8072-3A29-4076-9F64-D66F38349585}</Project>
|
||||
<Name>ChanSort.Loader.Panasonic</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ChanSort.Loader.ScmFile\ChanSort.Loader.Samsung.csproj">
|
||||
<Project>{A1C9A98D-368A-44E8-9B7F-7EACA46C9EC5}</Project>
|
||||
<Name>ChanSort.Loader.Samsung</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ChanSort.Loader.TllFile\ChanSort.Loader.LG.csproj">
|
||||
<Project>{E972D8A1-2F5F-421C-AC91-CFF45E5191BE}</Project>
|
||||
<Name>ChanSort.Loader.TllFile</Name>
|
||||
<Name>ChanSort.Loader.LG</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
@@ -1,197 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using ChanSort.Loader.TllFile;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Test.Loader.TllFile
|
||||
{
|
||||
[TestClass]
|
||||
public class UnitTest1
|
||||
{
|
||||
#region class ExpectedData
|
||||
public class ExpectedData
|
||||
{
|
||||
public readonly string File;
|
||||
public readonly int AnalogChannels;
|
||||
public readonly int DtvChannels;
|
||||
public readonly int SatChannels;
|
||||
public readonly int DtvRadio;
|
||||
public readonly int SatRadio;
|
||||
|
||||
public ExpectedData(string file, int analog, int dtv, int sat, int dtvRadio, int satRadio)
|
||||
{
|
||||
this.File = file;
|
||||
this.AnalogChannels = analog;
|
||||
this.DtvChannels = dtv;
|
||||
this.SatChannels = sat;
|
||||
this.DtvRadio = dtvRadio;
|
||||
this.SatRadio = satRadio;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private readonly Dictionary<string, ExpectedData> expectedData = new Dictionary<string, ExpectedData>();
|
||||
|
||||
#region ctor()
|
||||
public UnitTest1()
|
||||
{
|
||||
var expected = new [] {
|
||||
new ExpectedData(@"opel\xx2350D-PZM00001.TLL", 31, 345, 0, 89, 0), // 164/-
|
||||
new ExpectedData(@"defycgn\xxLH4010-ZD99970.TLL", 34, 280, 0, 129, 0), // 164/-
|
||||
new ExpectedData(@"karlv\xxLD750-ZA00001.TLL", 30, 248, 0, 104, 0), // 176/-
|
||||
new ExpectedData(@"JLevi\xxLE5500-ZA00002.TLL", 36, 0, 0,0, 0), // 176/-
|
||||
new ExpectedData(@"chlabnet\xxLK450-ZB00001.TLL", 34, 310, 0, 128, 0), // 176/-
|
||||
new ExpectedData(@"Stabilo\xxLW4500-ZB00001.TLL", 31 ,338, 0, 34, 0), // 176/-
|
||||
new ExpectedData(@"MarioAntonioLiptaj\xxPT353-ZA00001.TLL", 50, 123, 0, 13, 0), // 180/-
|
||||
new ExpectedData(@"Muffix\xxLW5500-ZE00001.TLL", 34, 290, 0, 125, 0), // 184/-
|
||||
new ExpectedData(@"FranzSteinert\xxCS460S-ZA00001.TLL", 0, 0, 1261, 0, 200), // ?/68
|
||||
new ExpectedData(@"Klausi1\xxLK950S-ZA00001.TLL", 37, 390, 2695, 150, 491), // 184/68
|
||||
new ExpectedData(@"MP3Chris2712\xxLV570S-ZB00001.TLL", 0, 12, 2895, 0, 669), // 184/68
|
||||
new ExpectedData(@"decklen\xxLW570S-ZD00001.TLL", 0, 30, 1598, 0, 339), // 184/68
|
||||
new ExpectedData(@"NeuerScan\xxLM340S-ZA00001.TLL", 34, 317, 1698, 129, 264), // 188/68
|
||||
new ExpectedData(@"wagnale\xxLM611S-ZA00001.TLL", 0, 13, 1094, 0, 191), // 188/68
|
||||
new ExpectedData(@"_Pred\xxLM620S-ZE00021.TLL", 0, 11, 1303, 0, 191) // 192/72
|
||||
};
|
||||
|
||||
foreach (var entry in expected)
|
||||
this.expectedData[entry.File] = entry;
|
||||
}
|
||||
#endregion
|
||||
|
||||
[TestMethod]
|
||||
public void MetaTest()
|
||||
{
|
||||
}
|
||||
|
||||
#region TestLoadingAllTllFilesInTestFilesDirectory()
|
||||
[TestMethod]
|
||||
[DeploymentItem("ChanSort.Loader.TllFile\\ChanSort.Loader.TllFile.ini")]
|
||||
public void TestLoadingAllTllFilesInTestFilesDirectory()
|
||||
{
|
||||
TllFileSerializerPlugin plugin = new TllFileSerializerPlugin();
|
||||
|
||||
StringBuilder errors = new StringBuilder();
|
||||
var list = this.FindAllTllFiles();
|
||||
var models = new Dictionary<string,string>();
|
||||
var firmwareSize = new Dictionary<int, string>();
|
||||
foreach(var file in list)
|
||||
{
|
||||
if (file.Contains("GlobalClone") || file.Contains("CountrySettings"))
|
||||
continue;
|
||||
Debug.Print("Testing " + file);
|
||||
try
|
||||
{
|
||||
var serializer = plugin.CreateSerializer(file) as TllFileSerializer;
|
||||
Assert.IsNotNull(serializer, "No Serializer for " + file);
|
||||
|
||||
serializer.Load();
|
||||
|
||||
var fileName = Path.GetFileName(file) ?? "";
|
||||
int idx = fileName.IndexOf("-");
|
||||
string key = idx < 0 ? fileName : fileName.Substring(0, idx);
|
||||
var satChannelList = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.DvbS|ChanSort.Api.SignalSource.Tv);
|
||||
key += "\t" + serializer.ACTChannelLength+
|
||||
"\t"+serializer.HasDvbs+
|
||||
"\t"+serializer.SatChannelLength+
|
||||
"\t" + (satChannelList == null ? "n/a" : satChannelList.Count.ToString());
|
||||
string relPath = Path.GetFileName(Path.GetDirectoryName(file))+"\\"+fileName;
|
||||
models[key] = relPath;
|
||||
|
||||
var model = this.GetModel(file);
|
||||
if (firmwareSize.ContainsKey(serializer.FirmwareBlockSize))
|
||||
{
|
||||
string x = firmwareSize[serializer.FirmwareBlockSize];
|
||||
if (!x.Contains(model))
|
||||
firmwareSize[serializer.FirmwareBlockSize] = x + ", " + model;
|
||||
}
|
||||
else
|
||||
firmwareSize[serializer.FirmwareBlockSize] = model;
|
||||
|
||||
|
||||
|
||||
Assert.IsFalse(serializer.DataRoot.IsEmpty, "No channels loaded from " + file);
|
||||
|
||||
ExpectedData exp;
|
||||
key = Path.GetFileName(Path.GetDirectoryName(file)) + "\\" + Path.GetFileName(file);
|
||||
this.expectedData.TryGetValue(key, out exp);
|
||||
var analogTv = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.AnalogCT|ChanSort.Api.SignalSource.Tv);
|
||||
var dtvTv = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.DvbCT|ChanSort.Api.SignalSource.Tv);
|
||||
var satTv = serializer.DataRoot.GetChannelList(ChanSort.Api.SignalSource.DvbS | ChanSort.Api.SignalSource.Tv);
|
||||
if (exp != null)
|
||||
{
|
||||
this.expectedData.Remove(key);
|
||||
Assert.AreEqual(exp.AnalogChannels, analogTv.Channels.Count, file + ": analog");
|
||||
Assert.AreEqual(exp.DtvChannels, dtvTv.Channels.Count, file + ": DTV");
|
||||
Assert.AreEqual(exp.SatChannels, satTv.Channels.Count, file + ": Sat");
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
errors.AppendLine();
|
||||
errors.AppendLine();
|
||||
errors.AppendLine(file);
|
||||
errors.AppendLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var model in models.OrderBy(e => e.Key))
|
||||
Debug.WriteLine(model.Key + "\t"+model.Value);
|
||||
|
||||
foreach (var size in firmwareSize.OrderBy(e => e.Key))
|
||||
Debug.WriteLine(size.Key + "\t" + size.Value);
|
||||
|
||||
if (this.expectedData.Count > 0)
|
||||
Assert.Fail("Some files were not tested: " + this.expectedData.Keys.Aggregate((prev,cur) => prev+","+cur));
|
||||
Assert.AreEqual("", errors.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
private string GetModel(string filePath)
|
||||
{
|
||||
string name = Path.GetFileName(filePath)??"";
|
||||
if (name.StartsWith("xx"))
|
||||
{
|
||||
int idx = name.IndexOf("-");
|
||||
if (idx > 0)
|
||||
return name.Substring(2, idx - 2);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
private IEnumerable<string> FindAllTllFiles()
|
||||
{
|
||||
string path = this.GetTestFileDirectory();
|
||||
List<string> files = new List<string>();
|
||||
this.FindAllTllFilesRecursively(path, files);
|
||||
return files;
|
||||
}
|
||||
|
||||
private string GetTestFileDirectory()
|
||||
{
|
||||
string exeDir = Assembly.GetExecutingAssembly().Location;
|
||||
while (!string.IsNullOrEmpty(exeDir))
|
||||
{
|
||||
string testFileDir = Path.Combine(exeDir, "TestFiles");
|
||||
if (Directory.Exists(testFileDir))
|
||||
return testFileDir;
|
||||
exeDir = Path.GetDirectoryName(exeDir);
|
||||
}
|
||||
throw new FileNotFoundException("No 'TestFiles' directory found");
|
||||
}
|
||||
|
||||
private void FindAllTllFilesRecursively(string path, List<string> files)
|
||||
{
|
||||
files.AddRange(Directory.GetFiles(path, "*.TLL"));
|
||||
foreach (var dir in Directory.GetDirectories(path))
|
||||
this.FindAllTllFilesRecursively(dir, files);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user