|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|
|
|
|
{
|
|
|
|
|
var dist = new Distance();
|
|
|
|
|
dist.Add("add", 1.0);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"add", new List<double> { 1.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"add", new List<double> { 1.0 }}} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -22,13 +22,13 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|
|
|
|
{
|
|
|
|
|
var dist = new Distance();
|
|
|
|
|
dist.AddEquality("equality", "ghi", new List<string> { "abc", "def", "ghi" });
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"equality", new List<double> { 0.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"equality", new List<double> { 0.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddEquality("equality", "xyz", new List<string> { "abc", "def", "ghi" });
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"equality", new List<double> { 0.0, 1.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"equality", new List<double> { 0.0, 1.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddEquality("equality", "abc", new List<string> { "abc", "def", "ghi" });
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"equality", new List<double> { 0.0, 1.0, 0.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"equality", new List<double> { 0.0, 1.0, 0.0 }}} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -36,10 +36,10 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|
|
|
|
{
|
|
|
|
|
var dist = new Distance();
|
|
|
|
|
dist.AddBool("expr", true);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"expr", new List<double> { 1.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"expr", new List<double> { 1.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddBool("expr", false);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"expr", new List<double> { 1.0, 0.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"expr", new List<double> { 1.0, 0.0 }}} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -47,16 +47,16 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|
|
|
|
{
|
|
|
|
|
var dist = new Distance();
|
|
|
|
|
dist.AddNumber("number", 1, 1);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"number", new List<double> { 0.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"number", new List<double> { 0.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddNumber("number", 1, 2);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"number", new List<double> { 0.0, 1.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"number", new List<double> { 0.0, 1.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddNumber("number", 2, 1);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"number", new List<double> { 0.0, 1.0, 1.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"number", new List<double> { 0.0, 1.0, 1.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddNumber("number", -1, 2);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"number", new List<double> { 0.0, 1.0, 1.0, 1.0, 1.0, 1.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"number", new List<double> { 0.0, 1.0, 1.0, 1.0, 1.0, 1.0 }}} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -64,13 +64,13 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|
|
|
|
{
|
|
|
|
|
var dist = new Distance();
|
|
|
|
|
dist.AddPriority("priority", "abc", new List<string> { "abc" });
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddPriority("priority", "def", new List<string> { "abc", "def" });
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0, 0.5 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0, 0.5 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddPriority("priority", "xyz", new List<string> { "abc", "def" });
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0, 0.5, 1.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0, 0.5, 1.0 }}} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -78,16 +78,16 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|
|
|
|
{
|
|
|
|
|
var dist = new Distance();
|
|
|
|
|
dist.AddPriority("priority", new List<string> { "abc" }, new List<string> { "abc" });
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddPriority("priority", new List<string> { "def" }, new List<string> { "abc" });
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0, 1.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0, 1.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddPriority("priority", new List<string> { "abc", "xyz" }, new List<string> { "abc" });
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0, 1.0, 0.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0, 1.0, 0.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddPriority("priority", new List<string> { "def", "xyz" }, new List<string> { "abc", "def" });
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0, 1.0, 0.0, 0.5 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"priority", new List<double> { 0.0, 1.0, 0.0, 0.5 }}} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -95,16 +95,16 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|
|
|
|
{
|
|
|
|
|
var dist = new Distance();
|
|
|
|
|
dist.AddRatio("ratio", 25, 100);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"ratio", new List<double> { 0.25 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"ratio", new List<double> { 0.25 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddRatio("ratio", 10, 5);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"ratio", new List<double> { 0.25, 1.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"ratio", new List<double> { 0.25, 1.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddRatio("ratio", -5, 5);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"ratio", new List<double> { 0.25, 1.0, 0.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"ratio", new List<double> { 0.25, 1.0, 0.0 }}} );
|
|
|
|
|
|
|
|
|
|
dist.AddRatio("ratio", 5, 0);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"ratio", new List<double> { 0.25, 1.0, 0.0, 0.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"ratio", new List<double> { 0.25, 1.0, 0.0, 0.0 }}} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|
|
|
|
{
|
|
|
|
|
var dist = new Distance();
|
|
|
|
|
dist.AddString("string", "abcd", "bcde");
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"string", new List<double> { 0.5 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"string", new List<double> { 0.5 }}} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -120,7 +120,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|
|
|
|
{
|
|
|
|
|
var dist = new Distance();
|
|
|
|
|
dist.AddString("string", string.Empty, "bcd");
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"string", new List<double> { 1.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"string", new List<double> { 1.0 }}} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
|
|
|
|
{
|
|
|
|
|
var dist = new Distance();
|
|
|
|
|
dist.AddString("string", string.Empty, string.Empty);
|
|
|
|
|
dist.Penalties.ShouldBeEquivalentTo(new Dictionary<string, List<double>> { {"string", new List<double> { 0.0 }}} );
|
|
|
|
|
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { {"string", new List<double> { 0.0 }}} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|