mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-27 18:10:54 +01:00
Merge pull request #5861 from BaronGreenback/ProfileMatch
Change profile matching to match what the web interface says.
(cherry picked from commit 12496677bd)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
committed by
Joshua M. Boniface
parent
cf0da1de86
commit
53239b0529
131
tests/Jellyfin.Dlna.Tests/DlnaManagerTests.cs
Normal file
131
tests/Jellyfin.Dlna.Tests/DlnaManagerTests.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using Emby.Dlna;
|
||||
using Emby.Dlna.PlayTo;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Dlna.Tests
|
||||
{
|
||||
public class DlnaManagerTests
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsMatch_GivenMatchingName_ReturnsTrue()
|
||||
{
|
||||
var device = new DeviceInfo()
|
||||
{
|
||||
Name = "My Device",
|
||||
Manufacturer = "LG Electronics",
|
||||
ManufacturerUrl = "http://www.lge.com",
|
||||
ModelDescription = "LG WebOSTV DMRplus",
|
||||
ModelName = "LG TV",
|
||||
ModelNumber = "1.0",
|
||||
};
|
||||
|
||||
var profile = new DeviceProfile()
|
||||
{
|
||||
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 ()
|
||||
{
|
||||
FriendlyName = "My Device",
|
||||
Manufacturer = "LG Electronics",
|
||||
ManufacturerUrl = "http://www.lge.com",
|
||||
ModelDescription = "LG WebOSTV DMRplus",
|
||||
ModelName = "LG TV",
|
||||
ModelNumber = "1.0",
|
||||
}
|
||||
};
|
||||
|
||||
var profile2 = new DeviceProfile()
|
||||
{
|
||||
Name = "Test Profile",
|
||||
FriendlyName = "My Device",
|
||||
Identification = new DeviceIdentification()
|
||||
{
|
||||
FriendlyName = "My Device",
|
||||
}
|
||||
};
|
||||
|
||||
var deviceMatch = GetManager().IsMatch(device.ToDeviceIdentification(), profile2.Identification);
|
||||
var deviceMatch2 = GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification);
|
||||
|
||||
Assert.True(deviceMatch);
|
||||
Assert.True(deviceMatch2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsMatch_GivenNamesAndManufacturersDoNotMatch_ReturnsFalse()
|
||||
{
|
||||
var device = new DeviceInfo()
|
||||
{
|
||||
Name = "My Device",
|
||||
Manufacturer = "JVC"
|
||||
};
|
||||
|
||||
var profile = new DeviceProfile()
|
||||
{
|
||||
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 ()
|
||||
{
|
||||
FriendlyName = "My Device",
|
||||
Manufacturer = "LG Electronics",
|
||||
ManufacturerUrl = "http://www.lge.com",
|
||||
ModelDescription = "LG WebOSTV DMRplus",
|
||||
ModelName = "LG TV",
|
||||
ModelNumber = "1.0",
|
||||
}
|
||||
};
|
||||
|
||||
var deviceMatch = GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification);
|
||||
|
||||
Assert.False(deviceMatch);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsMatch_GivenNamesAndRegExMatch_ReturnsTrue()
|
||||
{
|
||||
var device = new DeviceInfo()
|
||||
{
|
||||
Name = "My Device"
|
||||
};
|
||||
|
||||
var profile = new DeviceProfile()
|
||||
{
|
||||
Name = "Test Profile",
|
||||
FriendlyName = "My .*",
|
||||
Identification = new ()
|
||||
};
|
||||
|
||||
var deviceMatch = GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification);
|
||||
|
||||
Assert.True(deviceMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.3.0" />
|
||||
|
||||
Reference in New Issue
Block a user