1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-25 22:46:31 -04:00

Fixed: Commas in Must (Not) Contain regex

Closes #4672
This commit is contained in:
Mark McDowall
2021-10-02 17:54:52 -07:00
parent f6fbd3cfee
commit ada01a1116
10 changed files with 85 additions and 30 deletions
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
@@ -33,7 +34,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Mocker.SetConstant<ITermMatcherService>(Mocker.Resolve<TermMatcherService>());
}
private void GivenRestictions(string required, string ignored)
private void GivenRestictions(List<string> required, List<string> ignored)
{
Mocker.GetMock<IReleaseProfileService>()
.Setup(s => s.EnabledForTags(It.IsAny<HashSet<int>>(), It.IsAny<int>()))
@@ -60,7 +61,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void should_be_true_when_title_contains_one_required_term()
{
GivenRestictions("WEBRip", null);
GivenRestictions(new List<string> { "WEBRip" }, null);
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
}
@@ -68,7 +69,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void should_be_false_when_title_does_not_contain_any_required_terms()
{
GivenRestictions("doesnt,exist", null);
GivenRestictions(new List<string> { "doesnt", "exist" }, null);
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
}
@@ -76,7 +77,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void should_be_true_when_title_does_not_contain_any_ignored_terms()
{
GivenRestictions(null, "ignored");
GivenRestictions(null, new List<string> { "ignored" });
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
}
@@ -84,7 +85,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void should_be_false_when_title_contains_one_anded_ignored_terms()
{
GivenRestictions(null, "edited");
GivenRestictions(null, new List<string> { "edited" });
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
}
@@ -95,7 +96,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[TestCase("X264,NOTTHERE")]
public void should_ignore_case_when_matching_required(string required)
{
GivenRestictions(required, null);
GivenRestictions(required.Split(',').ToList(), null);
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
}
@@ -106,7 +107,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[TestCase("X264,NOTTHERE")]
public void should_ignore_case_when_matching_ignored(string ignored)
{
GivenRestictions(null, ignored);
GivenRestictions(null, ignored.Split(',').ToList());
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
}
@@ -120,7 +121,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Setup(s => s.EnabledForTags(It.IsAny<HashSet<int>>(), It.IsAny<int>()))
.Returns(new List<ReleaseProfile>
{
new ReleaseProfile { Required = "x264", Ignored = "www.Speed.cd" }
new ReleaseProfile
{
Required = new List<string> { "x264" },
Ignored = new List<string> { "www.Speed.cd" }
}
});
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
@@ -132,7 +137,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[TestCase(@"/\.WEB/", true)]
public void should_match_perl_regex(string pattern, bool expected)
{
GivenRestictions(pattern, null);
GivenRestictions(pattern.Split(',').ToList(), null);
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().Be(expected);
}