2019-11-08 02:31:44 +01:00
|
|
|
|
using System.Linq;
|
2019-08-29 16:57:20 +02:00
|
|
|
|
using ChanSort.Api;
|
|
|
|
|
|
using ChanSort.Loader.VDR;
|
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Test.Loader.VDR
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestClass]
|
|
|
|
|
|
public class LinuxVdrTest
|
|
|
|
|
|
{
|
|
|
|
|
|
#region TestAstraChannelsAddedToCorrectLists
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
|
public void TestAstraChannelsAddedToCorrectLists()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.TestChannelsAddedToCorrectLists("channels.conf", 3380, 2649, 492);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region TestChannelsAddedToCorrectList
|
|
|
|
|
|
private void TestChannelsAddedToCorrectLists(string fileName, int expectedTotal, int expectedTv, int expectedRadio)
|
|
|
|
|
|
{
|
2019-11-08 02:31:44 +01:00
|
|
|
|
var tempFile = TestUtils.DeploymentItem("Test.Loader.VDR\\TestFiles\\channels.conf");
|
2021-01-23 14:22:18 +01:00
|
|
|
|
var plugin = new VdrPlugin();
|
2019-11-08 02:31:44 +01:00
|
|
|
|
var ser = plugin.CreateSerializer(tempFile);
|
2019-08-29 16:57:20 +02:00
|
|
|
|
ser.Load();
|
|
|
|
|
|
|
|
|
|
|
|
var root = ser.DataRoot;
|
|
|
|
|
|
|
|
|
|
|
|
var list = root.ChannelLists.FirstOrDefault();
|
|
|
|
|
|
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 in channels.conf files
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-08 02:31:44 +01:00
|
|
|
|
#region TestDeletingChannel
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
|
public void TestDeletingChannel()
|
|
|
|
|
|
{
|
|
|
|
|
|
var tempFile = TestUtils.DeploymentItem("Test.Loader.VDR\\TestFiles\\channels.conf");
|
2021-01-23 14:22:18 +01:00
|
|
|
|
var plugin = new VdrPlugin();
|
2019-11-08 02:31:44 +01:00
|
|
|
|
var ser = plugin.CreateSerializer(tempFile);
|
|
|
|
|
|
ser.Load();
|
|
|
|
|
|
var data = ser.DataRoot;
|
|
|
|
|
|
data.ValidateAfterLoad();
|
|
|
|
|
|
data.ApplyCurrentProgramNumbers();
|
|
|
|
|
|
|
|
|
|
|
|
// Pr# 421 = ORF2E
|
|
|
|
|
|
|
|
|
|
|
|
var dvbs = data.GetChannelList(SignalSource.DvbS);
|
|
|
|
|
|
var orf2e = dvbs.Channels.FirstOrDefault(ch => ch.Name == "ORF2E");
|
|
|
|
|
|
Assert.IsNotNull(orf2e);
|
|
|
|
|
|
Assert.AreEqual(421, orf2e.OldProgramNr);
|
|
|
|
|
|
Assert.AreEqual(421, orf2e.NewProgramNr);
|
|
|
|
|
|
Assert.IsFalse(orf2e.IsDeleted);
|
|
|
|
|
|
|
|
|
|
|
|
orf2e.NewProgramNr = -1;
|
2019-11-08 19:35:59 +01:00
|
|
|
|
data.AssignNumbersToUnsortedAndDeletedChannels(UnsortedChannelMode.Delete);
|
2019-11-08 02:31:44 +01:00
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(orf2e.IsDeleted);
|
|
|
|
|
|
Assert.IsTrue(orf2e.NewProgramNr == 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// save and reload
|
2022-11-29 22:00:16 +01:00
|
|
|
|
ser.Save();
|
2019-11-08 02:31:44 +01:00
|
|
|
|
ser = plugin.CreateSerializer(tempFile);
|
|
|
|
|
|
ser.Load();
|
|
|
|
|
|
data = ser.DataRoot;
|
|
|
|
|
|
data.ValidateAfterLoad();
|
|
|
|
|
|
data.ApplyCurrentProgramNumbers();
|
|
|
|
|
|
|
|
|
|
|
|
// channel was deleted from file
|
|
|
|
|
|
dvbs = data.GetChannelList(SignalSource.DvbS);
|
|
|
|
|
|
orf2e = dvbs.Channels.FirstOrDefault(ch => ch.Name == "ORF2E");
|
|
|
|
|
|
Assert.IsNull(orf2e);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2021-03-14 22:13:22 +01:00
|
|
|
|
|
|
|
|
|
|
#region TestChannelAndFavListEditing
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
|
public void TestChannelAndFavListEditing()
|
|
|
|
|
|
{
|
|
|
|
|
|
var tempFile = TestUtils.DeploymentItem("Test.Loader.VDR\\TestFiles\\channels.conf");
|
|
|
|
|
|
RoundtripTest.TestChannelAndFavListEditing(tempFile, new VdrPlugin());
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2019-08-29 16:57:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|