mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-01-17 12:52:05 +01:00
- ChannelList.SignalSource and DataRoot.GetChannelList(SignalSource) are now handled so that if all bits of a given Mask are left 0, the list will accept anything. i.e. if Tv/Radio/Data is left 0, the list can contain all of them as well as channels that have neither of the 3 bits set. - added basic unit tests for each loader to ensure test files have the expected numbers of channels in the various sub lists
69 lines
2.2 KiB
C#
69 lines
2.2 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using ChanSort.Api;
|
|
using ChanSort.Loader.PhilipsXml;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
namespace Test.Loader.PhilipsXml
|
|
{
|
|
[TestClass]
|
|
public class PhilipsXmlTest
|
|
{
|
|
private static readonly string filesDir;
|
|
|
|
static PhilipsXmlTest()
|
|
{
|
|
filesDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\TestFiles\\";
|
|
}
|
|
|
|
#region TestFormat1SatChannelsAddedToCorrectLists
|
|
[TestMethod]
|
|
public void TestFormat1SatChannelsAddedToCorrectLists()
|
|
{
|
|
this.TestChannelsAddedToCorrectLists("DVBS.xml", SignalSource.DvbS, 502, 350, 152);
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region TestFormat1CableChannelsAddedToCorrectLists
|
|
[TestMethod]
|
|
public void TestFormat1CableChannelsAddedToCorrectLists()
|
|
{
|
|
this.TestChannelsAddedToCorrectLists("DVBC.xml", SignalSource.DvbC, 459, 358, 101);
|
|
}
|
|
#endregion
|
|
|
|
#region TestFormat2CableChannelsAddedToCorrectLists
|
|
[TestMethod]
|
|
public void TestFormat2CableChannelsAddedToCorrectLists()
|
|
{
|
|
// this file format doesn't provide any information whether a channel is TV/radio/data or analog/digital. It only contains the "medium" for antenna/cable/sat
|
|
this.TestChannelsAddedToCorrectLists("CM_TPM1013E_LA_CK.xml", SignalSource.DvbC, 483, 0, 0);
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region TestChannelsAddedToCorrectList
|
|
private void TestChannelsAddedToCorrectLists(string fileName, SignalSource signalSource, int expectedTotal, int expectedTv, int expectedRadio)
|
|
{
|
|
var plugin = new SerializerPlugin();
|
|
var ser = plugin.CreateSerializer(filesDir + fileName);
|
|
ser.Load();
|
|
|
|
var root = ser.DataRoot;
|
|
|
|
var list = root.GetChannelList(signalSource);
|
|
Assert.IsNotNull(list);
|
|
Assert.AreEqual(expectedTotal, list.Channels.Count);
|
|
Assert.AreEqual(expectedTv, list.Channels.Count(ch => (ch.SignalSource & SignalSource.Tv) != 0));
|
|
Assert.AreEqual(expectedRadio, list.Channels.Count(ch => (ch.SignalSource & SignalSource.Radio) != 0));
|
|
|
|
// no data channels found in any of the Philips channel lists available to me
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|