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

108 lines
3.6 KiB
C#
Raw Normal View History

2021-04-19 06:07:14 -07:00
using Emby.Dlna;
2021-04-19 04:36:30 -07:00
using Emby.Dlna.PlayTo;
2021-04-20 10:04:16 -07:00
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller;
2021-04-19 04:36:30 -07:00
using MediaBrowser.Model.Dlna;
2021-04-20 10:04:16 -07:00
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
using Moq;
2021-04-19 04:36:30 -07:00
using Xunit;
namespace Jellyfin.Dlna.Tests
{
public class DlnaManagerTests
2021-04-19 04:36:30 -07:00
{
2021-04-20 10:04:16 -07: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 06:07:14 -07:00
[Fact]
public void Test_Profile_Matches()
2021-04-19 04:36:30 -07:00
{
2021-04-19 06:07:14 -07:00
var device = new DeviceInfo()
2021-04-19 04:36:30 -07:00
{
2021-04-19 06:07:14 -07: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 04:36:30 -07:00
2021-04-19 06:07:14 -07:00
var profile = new DeviceProfile()
2021-04-19 04:36:30 -07:00
{
2021-04-19 06:07:14 -07: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 04:36:30 -07:00
{
2021-04-19 06:07:14 -07: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 04:36:30 -07:00
}
2021-04-19 06:07:14 -07:00
};
2021-04-19 04:36:30 -07:00
2021-04-20 10:04:16 -07:00
Assert.True(GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification));
2021-04-19 04:36:30 -07:00
2021-04-19 06:07:14 -07:00
var profile2 = new DeviceProfile()
2021-04-19 04:36:30 -07:00
{
2021-04-19 06:07:14 -07:00
Name = "Test Profile",
FriendlyName = "My Device",
Identification = new DeviceIdentification()
2021-04-19 04:36:30 -07:00
{
2021-04-19 06:07:14 -07:00
FriendlyName = "My Device",
2021-04-19 04:36:30 -07:00
}
2021-04-19 06:07:14 -07:00
};
2021-04-19 04:36:30 -07:00
2021-04-20 10:04:16 -07:00
Assert.True(GetManager().IsMatch(device.ToDeviceIdentification(), profile2.Identification));
2021-04-19 04:36:30 -07:00
}
[Fact]
2021-04-19 06:07:14 -07:00
public void Test_Profile_NoMatch()
2021-04-19 04:36:30 -07:00
{
2021-04-19 06:07:14 -07:00
var device = new DeviceInfo()
2021-04-19 04:36:30 -07:00
{
2021-04-19 06:07:14 -07:00
Name = "My Device",
Manufacturer = "JVC"
2021-04-19 04:36:30 -07:00
};
2021-04-19 06:07:14 -07:00
var profile = new DeviceProfile()
2021-04-19 04:36:30 -07:00
{
2021-04-19 06:07:14 -07:00
Name = "Test Profile",
FriendlyName = "My Device",
2021-04-19 04:36:30 -07: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 06:07:14 -07:00
FriendlyName = "My Device",
2021-04-19 04:36:30 -07:00
Manufacturer = "LG Electronics",
ManufacturerUrl = "http://www.lge.com",
ModelDescription = "LG WebOSTV DMRplus",
ModelName = "LG TV",
ModelNumber = "1.0",
}
};
2021-04-20 10:04:16 -07:00
Assert.False(GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification));
2021-04-19 04:36:30 -07:00
}
}
}