mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-08-30 23:00:18 -04:00
Changes as requested
This commit is contained in:
parent
39eb5da44f
commit
53e1b302cc
@ -150,13 +150,13 @@ namespace Emby.Dlna
|
|||||||
public bool IsMatch(DeviceIdentification deviceInfo, DeviceIdentification profileInfo)
|
public bool IsMatch(DeviceIdentification deviceInfo, DeviceIdentification profileInfo)
|
||||||
{
|
{
|
||||||
return IsRegexOrSubstringMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName)
|
return IsRegexOrSubstringMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName)
|
||||||
&& IsRegexOrSubstringMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer)
|
&& IsRegexOrSubstringMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer)
|
||||||
&& IsRegexOrSubstringMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl)
|
&& IsRegexOrSubstringMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl)
|
||||||
&& IsRegexOrSubstringMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription)
|
&& IsRegexOrSubstringMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription)
|
||||||
&& IsRegexOrSubstringMatch(deviceInfo.ModelName, profileInfo.ModelName)
|
&& IsRegexOrSubstringMatch(deviceInfo.ModelName, profileInfo.ModelName)
|
||||||
&& IsRegexOrSubstringMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber)
|
&& IsRegexOrSubstringMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber)
|
||||||
&& IsRegexOrSubstringMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl)
|
&& IsRegexOrSubstringMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl)
|
||||||
&& IsRegexOrSubstringMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber);
|
&& IsRegexOrSubstringMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsRegexOrSubstringMatch(string input, string pattern)
|
private bool IsRegexOrSubstringMatch(string input, string pattern)
|
||||||
|
@ -46,7 +46,7 @@ namespace Jellyfin.Dlna.Tests
|
|||||||
ModelDescription = "LG WebOSTV DMRplus",
|
ModelDescription = "LG WebOSTV DMRplus",
|
||||||
ModelName = "LG TV",
|
ModelName = "LG TV",
|
||||||
ModelNumber = "1.0",
|
ModelNumber = "1.0",
|
||||||
Identification = new DeviceIdentification()
|
Identification = new ()
|
||||||
{
|
{
|
||||||
FriendlyName = "My Device",
|
FriendlyName = "My Device",
|
||||||
Manufacturer = "LG Electronics",
|
Manufacturer = "LG Electronics",
|
||||||
@ -69,7 +69,8 @@ namespace Jellyfin.Dlna.Tests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.True(GetManager().IsMatch(device.ToDeviceIdentification(), profile2.Identification));
|
var deviceMatch = GetManager().IsMatch(device.ToDeviceIdentification(), profile2.Identification);
|
||||||
|
Assert.True(deviceMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -90,7 +91,7 @@ namespace Jellyfin.Dlna.Tests
|
|||||||
ModelDescription = "LG WebOSTV DMRplus",
|
ModelDescription = "LG WebOSTV DMRplus",
|
||||||
ModelName = "LG TV",
|
ModelName = "LG TV",
|
||||||
ModelNumber = "1.0",
|
ModelNumber = "1.0",
|
||||||
Identification = new DeviceIdentification()
|
Identification = new ()
|
||||||
{
|
{
|
||||||
FriendlyName = "My Device",
|
FriendlyName = "My Device",
|
||||||
Manufacturer = "LG Electronics",
|
Manufacturer = "LG Electronics",
|
||||||
@ -101,7 +102,29 @@ namespace Jellyfin.Dlna.Tests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.False(GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user