mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-01-12 18:32:05 +01:00
- added "Pooling=False" parameter to all Sqlite connection strings to prevent open file locks after closing the connection and to avoid extreme delays when using CloseAllPools()
- C# code refactoring "using var" instead of "using ( ) { }" where possible
109 lines
3.3 KiB
C#
109 lines
3.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using ChanSort.Api;
|
|
using ChanSort.Loader.Panasonic;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
namespace Test.Loader.Panasonic
|
|
{
|
|
[TestClass]
|
|
public class PanasonicSvlTest
|
|
{
|
|
#region TestSatChannelsAddedToCorrectLists
|
|
[TestMethod]
|
|
public void TestSatChannelsAddedToCorrectLists()
|
|
{
|
|
this.TestChannelsAddedToCorrectLists("svl-sat.db", SignalSource.DvbS, 1187, 1028, 159);
|
|
}
|
|
#endregion
|
|
|
|
#region TestCableChannelsAddedToCorrectLists
|
|
[TestMethod]
|
|
public void TestCableChannelsAddedToCorrectLists()
|
|
{
|
|
this.TestChannelsAddedToCorrectLists("svl-cable.db", SignalSource.DvbC, 465, 304, 161);
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region TestChannelsAddedToCorrectList
|
|
private void TestChannelsAddedToCorrectLists(string fileName, SignalSource signalSource, int expectedTotal, int expectedTv, int expectedRadio)
|
|
{
|
|
var tempFile = TestUtils.DeploymentItem("Test.Loader.Panasonic\\TestFiles\\" + fileName);
|
|
var plugin = new PanasonicPlugin();
|
|
var ser = plugin.CreateSerializer(tempFile);
|
|
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));
|
|
|
|
// there are no data channels in Panasonic lists
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region TestDeletingChannel
|
|
|
|
[TestMethod]
|
|
public void TestDeletingChannel()
|
|
{
|
|
var tempFile = TestUtils.DeploymentItem("Test.Loader.Panasonic\\TestFiles\\svl-sat.db");
|
|
var plugin = new PanasonicPlugin();
|
|
var ser = plugin.CreateSerializer(tempFile);
|
|
ser.Load();
|
|
var data = ser.DataRoot;
|
|
data.ValidateAfterLoad();
|
|
data.ApplyCurrentProgramNumbers();
|
|
|
|
// Pr# 130 = ORF2E
|
|
|
|
var dvbs = data.GetChannelList(SignalSource.DvbS);
|
|
var orf2e = dvbs.Channels.FirstOrDefault(ch => ch.Name == "ORF2E");
|
|
Assert.IsNotNull(orf2e);
|
|
Assert.AreEqual(130, orf2e.OldProgramNr);
|
|
Assert.AreEqual(130, orf2e.NewProgramNr);
|
|
Assert.IsFalse(orf2e.IsDeleted);
|
|
|
|
orf2e.NewProgramNr = -1;
|
|
data.AssignNumbersToUnsortedAndDeletedChannels(UnsortedChannelMode.Delete);
|
|
|
|
Assert.IsTrue(orf2e.IsDeleted);
|
|
Assert.IsTrue(orf2e.NewProgramNr == 0);
|
|
Assert.AreEqual(1, dvbs.Channels.Count(ch => ch.NewProgramNr <= 0));
|
|
|
|
|
|
// save and reload
|
|
ser.Save();
|
|
ser = plugin.CreateSerializer(tempFile);
|
|
ser.Load();
|
|
data = ser.DataRoot;
|
|
data.ValidateAfterLoad();
|
|
data.ApplyCurrentProgramNumbers();
|
|
|
|
// channel was deleted from database
|
|
dvbs = data.GetChannelList(SignalSource.DvbS);
|
|
orf2e = dvbs.Channels.FirstOrDefault(ch => ch.Name == "ORF2E");
|
|
Assert.IsNull(orf2e);
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region TestChannelAndFavListEditing
|
|
[TestMethod]
|
|
public void TestChannelAndFavListEditing()
|
|
{
|
|
var tempFile = TestUtils.DeploymentItem("Test.Loader.Panasonic\\TestFiles\\svl-sat.db");
|
|
RoundtripTest.TestChannelAndFavListEditing(tempFile, new PanasonicPlugin());
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|