Fixed: Null Tag Handling

This commit is contained in:
bakerboy448
2025-09-05 09:41:27 -05:00
parent ffab40e923
commit 56480c7c0a
2 changed files with 26 additions and 2 deletions
@@ -163,5 +163,29 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
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 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
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())
{