mirror of
https://github.com/Lidarr/Lidarr
synced 2025-12-06 08:25:54 +01:00
Fixed: Null Tag Handling
This commit is contained in:
parent
ffab40e923
commit
56480c7c0a
2 changed files with 26 additions and 2 deletions
|
|
@ -163,5 +163,29 @@ public void test_raw_distance()
|
|||
|
||||
dist.RawDistance().Should().Be(2.25);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void test_add_string_null_handling()
|
||||
{
|
||||
var dist = new Distance();
|
||||
|
||||
dist.AddString("string", null, "target");
|
||||
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { { "string", new List<double> { 1.0 } } });
|
||||
|
||||
dist.AddString("string2", "value", null);
|
||||
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>>
|
||||
{
|
||||
{ "string", new List<double> { 1.0 } },
|
||||
{ "string2", new List<double> { 1.0 } }
|
||||
});
|
||||
|
||||
dist.AddString("string3", null, null);
|
||||
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>>
|
||||
{
|
||||
{ "string", new List<double> { 1.0 } },
|
||||
{ "string2", new List<double> { 1.0 } },
|
||||
{ "string3", new List<double> { 0.0 } }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,8 +125,8 @@ private static string Clean(string input)
|
|||
public void AddString(string key, string value, string target)
|
||||
{
|
||||
// Adds a penaltly based on the distance between value and target
|
||||
var cleanValue = Clean(value);
|
||||
var cleanTarget = Clean(target);
|
||||
var cleanValue = Clean(value ?? string.Empty);
|
||||
var cleanTarget = Clean(target ?? string.Empty);
|
||||
|
||||
if (cleanValue.IsNullOrWhiteSpace() && cleanTarget.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue