jellyfin/tests/Jellyfin.Dlna.Tests/ProfileTester.cs

108 lines
3.6 KiB
C#
Raw Normal View History

2021-04-19 15:07:14 +02:00
using Emby.Dlna;
2021-04-19 13:36:30 +02:00
using Emby.Dlna.PlayTo;
2021-04-20 19:04:16 +02:00
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller;
2021-04-19 13:36:30 +02:00
using MediaBrowser.Model.Dlna;
2021-04-20 19:04:16 +02:00
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
using Moq;
2021-04-19 13:36:30 +02:00
using Xunit;
namespace Jellyfin.Dlna.Tests
{
public class DlnaManagerTests
2021-04-19 13:36:30 +02:00
{
2021-04-20 19:04:16 +02:00
private DlnaManager GetManager()
{
var xmlSerializer = new Mock<IXmlSerializer>();
var fileSystem = new Mock<IFileSystem>();
var appPaths = new Mock<IApplicationPaths>();
var loggerFactory = new Mock<ILoggerFactory>();
var appHost = new Mock<IServerApplicationHost>();
return new DlnaManager(xmlSerializer.Object, fileSystem.Object, appPaths.Object, loggerFactory.Object, appHost.Object);
}
2021-04-19 15:07:14 +02:00
[Fact]
public void Test_Profile_Matches()
2021-04-19 13:36:30 +02:00
{
2021-04-19 15:07:14 +02:00
var device = new DeviceInfo()
2021-04-19 13:36:30 +02:00
{
2021-04-19 15:07:14 +02:00
Name = "My Device",
Manufacturer = "LG Electronics",
ManufacturerUrl = "http://www.lge.com",
ModelDescription = "LG WebOSTV DMRplus",
ModelName = "LG TV",
ModelNumber = "1.0",
};
2021-04-19 13:36:30 +02:00
2021-04-19 15:07:14 +02:00
var profile = new DeviceProfile()
2021-04-19 13:36:30 +02:00
{
2021-04-19 15:07:14 +02:00
Name = "Test Profile",
FriendlyName = "My Device",
Manufacturer = "LG Electronics",
ManufacturerUrl = "http://www.lge.com",
ModelDescription = "LG WebOSTV DMRplus",
ModelName = "LG TV",
ModelNumber = "1.0",
Identification = new DeviceIdentification()
2021-04-19 13:36:30 +02:00
{
2021-04-19 15:07:14 +02:00
FriendlyName = "My Device",
Manufacturer = "LG Electronics",
ManufacturerUrl = "http://www.lge.com",
ModelDescription = "LG WebOSTV DMRplus",
ModelName = "LG TV",
ModelNumber = "1.0",
2021-04-19 13:36:30 +02:00
}
2021-04-19 15:07:14 +02:00
};
2021-04-19 13:36:30 +02:00
2021-04-20 19:04:16 +02:00
Assert.True(GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification));
2021-04-19 13:36:30 +02:00
2021-04-19 15:07:14 +02:00
var profile2 = new DeviceProfile()
2021-04-19 13:36:30 +02:00
{
2021-04-19 15:07:14 +02:00
Name = "Test Profile",
FriendlyName = "My Device",
Identification = new DeviceIdentification()
2021-04-19 13:36:30 +02:00
{
2021-04-19 15:07:14 +02:00
FriendlyName = "My Device",
2021-04-19 13:36:30 +02:00
}
2021-04-19 15:07:14 +02:00
};
2021-04-19 13:36:30 +02:00
2021-04-20 19:04:16 +02:00
Assert.True(GetManager().IsMatch(device.ToDeviceIdentification(), profile2.Identification));
2021-04-19 13:36:30 +02:00
}
[Fact]
2021-04-19 15:07:14 +02:00
public void Test_Profile_NoMatch()
2021-04-19 13:36:30 +02:00
{
2021-04-19 15:07:14 +02:00
var device = new DeviceInfo()
2021-04-19 13:36:30 +02:00
{
2021-04-19 15:07:14 +02:00
Name = "My Device",
Manufacturer = "JVC"
2021-04-19 13:36:30 +02:00
};
2021-04-19 15:07:14 +02:00
var profile = new DeviceProfile()
2021-04-19 13:36:30 +02:00
{
2021-04-19 15:07:14 +02:00
Name = "Test Profile",
FriendlyName = "My Device",
2021-04-19 13:36:30 +02:00
Manufacturer = "LG Electronics",
ManufacturerUrl = "http://www.lge.com",
ModelDescription = "LG WebOSTV DMRplus",
ModelName = "LG TV",
ModelNumber = "1.0",
Identification = new DeviceIdentification()
{
2021-04-19 15:07:14 +02:00
FriendlyName = "My Device",
2021-04-19 13:36:30 +02:00
Manufacturer = "LG Electronics",
ManufacturerUrl = "http://www.lge.com",
ModelDescription = "LG WebOSTV DMRplus",
ModelName = "LG TV",
ModelNumber = "1.0",
}
};
2021-04-20 19:04:16 +02:00
Assert.False(GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification));
2021-04-19 13:36:30 +02:00
}
}
}