Skip to content

Commit

Permalink
Changes as requested
Browse files Browse the repository at this point in the history
  • Loading branch information
BaronGreenback committed Apr 21, 2021
1 parent 39eb5da commit 53e1b30
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
14 changes: 7 additions & 7 deletions Emby.Dlna/DlnaManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ private void LogUnmatchedProfile(DeviceIdentification profile)
public bool IsMatch(DeviceIdentification deviceInfo, DeviceIdentification profileInfo)
{
return IsRegexOrSubstringMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName)
&& IsRegexOrSubstringMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer)
&& IsRegexOrSubstringMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl)
&& IsRegexOrSubstringMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription)
&& IsRegexOrSubstringMatch(deviceInfo.ModelName, profileInfo.ModelName)
&& IsRegexOrSubstringMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber)
&& IsRegexOrSubstringMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl)
&& IsRegexOrSubstringMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber);
&& IsRegexOrSubstringMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer)
&& IsRegexOrSubstringMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl)
&& IsRegexOrSubstringMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription)
&& IsRegexOrSubstringMatch(deviceInfo.ModelName, profileInfo.ModelName)
&& IsRegexOrSubstringMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber)
&& IsRegexOrSubstringMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl)
&& IsRegexOrSubstringMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber);
}

private bool IsRegexOrSubstringMatch(string input, string pattern)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void IsMatch_GivenMatchingName_ReturnsTrue()
ModelDescription = "LG WebOSTV DMRplus",
ModelName = "LG TV",
ModelNumber = "1.0",
Identification = new DeviceIdentification()
Identification = new ()
{
FriendlyName = "My Device",
Manufacturer = "LG Electronics",
Expand All @@ -69,7 +69,8 @@ public void IsMatch_GivenMatchingName_ReturnsTrue()
}
};

Assert.True(GetManager().IsMatch(device.ToDeviceIdentification(), profile2.Identification));
var deviceMatch = GetManager().IsMatch(device.ToDeviceIdentification(), profile2.Identification);
Assert.True(deviceMatch);
}

[Fact]
Expand All @@ -90,7 +91,7 @@ public void IsMatch_GivenNamesAndManufacturersDoNotMatch_ReturnsFalse()
ModelDescription = "LG WebOSTV DMRplus",
ModelName = "LG TV",
ModelNumber = "1.0",
Identification = new DeviceIdentification()
Identification = new ()
{
FriendlyName = "My Device",
Manufacturer = "LG Electronics",
Expand All @@ -101,7 +102,29 @@ public void IsMatch_GivenNamesAndManufacturersDoNotMatch_ReturnsFalse()
}
};

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);
}
}
}

0 comments on commit 53e1b30

Please sign in to comment.