using System; using System.Collections.Generic; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests { [TestFixture] public class BlockedIndexerSpecificationFixture : CoreTest { private RemoteAlbum _remoteAlbum; [SetUp] public void Setup() { _remoteAlbum = new RemoteAlbum { Release = new ReleaseInfo { IndexerId = 1 } }; Mocker.GetMock() .Setup(v => v.GetBlockedProviders()) .Returns(new List()); } private void WithBlockedIndexer() { Mocker.GetMock() .Setup(v => v.GetBlockedProviders()) .Returns(new List { new IndexerStatus { ProviderId = 1, DisabledTill = DateTime.UtcNow } }); } [Test] public void should_return_true_if_no_blocked_indexer() { Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue(); } [Test] public void should_return_false_if_blocked_indexer() { WithBlockedIndexer(); Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse(); Subject.Type.Should().Be(RejectionType.Temporary); } } }