Moq.It.IsAny()

Here are the examples of the csharp api Moq.It.IsAny() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2353 Examples 7

19 Source : ProtocolSpecificationFixture.cs
with GNU General Public License v3.0
from bonarr

[SetUp]
        public void Setup()
        {
            _remoteEpisode = new RemoteEpisode();
            _remoteEpisode.Release = new ReleaseInfo();
            _remoteEpisode.Series = new Series();
            
            _delayProfile = new DelayProfile();

            Mocker.GetMock<IDelayProfileService>()
                  .Setup(s => s.BestForTags(It.IsAny<HashSet<int>>()))
                  .Returns(_delayProfile);
        }

19 Source : ReleaseRestrictionsSpecificationFixture.cs
with GNU General Public License v3.0
from bonarr

private void GivenRestictions(string required, string ignored)
        {
            Mocker.GetMock<IRestrictionService>()
                  .Setup(s => s.AllForTags(It.IsAny<HashSet<int>>()))
                  .Returns(new List<Restriction>
                           {
                               new Restriction
                               {
                                   Required = required,
                                   Ignored = ignored
                               }
                           });
        }

19 Source : ReleaseRestrictionsSpecificationFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_be_true_when_restrictions_are_empty()
        {
            Mocker.GetMock<IRestrictionService>()
                  .Setup(s => s.AllForTags(It.IsAny<HashSet<int>>()))
                  .Returns(new List<Restriction>());

            Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
        }

19 Source : ReleaseRestrictionsSpecificationFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_be_false_when_release_contains_one_restricted_word_and_one_required_word()
        {
            _remoteEpisode.Release.replacedle = "[ www.Speed.cd ] -Whose.Line.is.it.Anyway.US.S10E24.720p.HDTV.x264-BAJSKORV";

            Mocker.GetMock<IRestrictionService>()
                  .Setup(s => s.AllForTags(It.IsAny<HashSet<int>>()))
                  .Returns(new List<Restriction>
                           {
                               new Restriction { Required = "x264", Ignored = "www.Speed.cd" }
                           });

            Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
        }

19 Source : SameEpisodesSpecificationFixture.cs
with GNU General Public License v3.0
from bonarr

private void GivenEpisodesInFile(List<Episode> episodes)
        {
            Mocker.GetMock<IEpisodeService>()
                  .Setup(s => s.GetEpisodesByFileId(It.IsAny<int>()))
                  .Returns(episodes);
        }

19 Source : DownloadApprovedFixture.cs
with GNU General Public License v3.0
from bonarr

[SetUp]
        public void SetUp()
        {
            Mocker.GetMock<IPrioritizeDownloadDecision>()
                .Setup(v => v.PrioritizeDecisionsForMovies(It.IsAny<List<DownloadDecision>>()))
                .Returns<List<DownloadDecision>>(v => v);
        }

19 Source : DownloadApprovedFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_download_report_if_movie_was_not_already_downloaded()
        {
            var remoteMovie = GetRemoteMovie(new QualityModel(Quality.HDTV720p));

            var decisions = new List<DownloadDecision>();
            decisions.Add(new DownloadDecision(remoteMovie));

            Subject.ProcessDecisions(decisions);
            Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteMovie>(), false), Times.Once());
        }

19 Source : DownloadApprovedFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_only_download_movie_once()
        {
            var remoteMovie = GetRemoteMovie(new QualityModel(Quality.HDTV720p));

            var decisions = new List<DownloadDecision>();
            decisions.Add(new DownloadDecision(remoteMovie));
            decisions.Add(new DownloadDecision(remoteMovie));

            Subject.ProcessDecisions(decisions);
            Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteMovie>(), false), Times.Once());
        }

19 Source : DownloadApprovedFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_not_grab_if_pending()
        {
            var remoteMovie = GetRemoteMovie(new QualityModel(Quality.HDTV720p));

            var decisions = new List<DownloadDecision>();
            decisions.Add(new DownloadDecision(remoteMovie, new Rejection("Failure!", RejectionType.Temporary)));
            decisions.Add(new DownloadDecision(remoteMovie));

            Subject.ProcessDecisions(decisions);
            Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteMovie>(), false), Times.Never());
        }

19 Source : TorrentBlackholeFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void RemoveItem_should_delete_directory()
        {
            GivenCompletedItem();

            Mocker.GetMock<IDiskProvider>()
                .Setup(c => c.FolderExists(It.IsAny<string>()))
                .Returns(true);

            Subject.RemoveItem("_Droned.1998.1080p.WEB-DL-DRONE_0", true);

            Mocker.GetMock<IDiskProvider>()
                .Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Once());
        }

19 Source : DelugeFixture.cs
with GNU General Public License v3.0
from bonarr

[SetUp]
        public void Setup()
        {
            Subject.Definition = new DownloadClientDefinition();
            Subject.Definition.Settings = new DelugeSettings()
            {
                MovieCategory = null
            };

            _queued = new DelugeTorrent
                    {
                        Hash = "HASH",
                        IsFinished = false,
                        State = DelugeTorrentStatus.Queued,
                        Name = _replacedle,
                        Size = 1000,
                        BytesDownloaded = 0,
                        Progress = 0.0,
                        DownloadPath = "somepath"
                    };

            _downloading = new DelugeTorrent
                    {
                        Hash = "HASH",
                        IsFinished = false,
                        State = DelugeTorrentStatus.Downloading,
                        Name = _replacedle,
                        Size = 1000,
                        BytesDownloaded = 100,
                        Progress = 10.0,
                        DownloadPath = "somepath"
                    };

            _failed = new DelugeTorrent
                    {
                        Hash = "HASH",
                        IsFinished = false,
                        State = DelugeTorrentStatus.Error,
                        Name = _replacedle,
                        Size = 1000,
                        BytesDownloaded = 100,
                        Progress = 10.0,
                        Message = "Error",
                        DownloadPath = "somepath"
                    };

            _completed = new DelugeTorrent
                    {
                        Hash = "HASH",
                        IsFinished = true,
                        State = DelugeTorrentStatus.Paused,
                        Name = _replacedle,
                        Size = 1000,
                        BytesDownloaded = 1000,
                        Progress = 100.0,
                        DownloadPath = "somepath"
                    };

            Mocker.GetMock<ITorrentFileInfoReader>()
                  .Setup(s => s.GetHashFromTorrentFile(It.IsAny<byte[]>()))
                  .Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951");

            Mocker.GetMock<IHttpClient>()
                  .Setup(s => s.Get(It.IsAny<HttpRequest>()))
                  .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0]));
        }

19 Source : DelugeFixture.cs
with GNU General Public License v3.0
from bonarr

protected void GivenFailedDownload()
        {
            Mocker.GetMock<IDelugeProxy>()
                .Setup(s => s.AddTorrentFromMagnet(It.IsAny<string>(), It.IsAny<DelugeSettings>()))
                .Throws<InvalidOperationException>();

            Mocker.GetMock<IDelugeProxy>()
                .Setup(s => s.AddTorrentFromFile(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<DelugeSettings>()))
                .Throws<InvalidOperationException>();
        }

19 Source : DelugeFixture.cs
with GNU General Public License v3.0
from bonarr

protected void GivenSuccessfulDownload()
        {
            Mocker.GetMock<IHttpClient>()
                  .Setup(s => s.Get(It.IsAny<HttpRequest>()))
                  .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[1000]));

            Mocker.GetMock<IDelugeProxy>()
                .Setup(s => s.AddTorrentFromMagnet(It.IsAny<string>(), It.IsAny<DelugeSettings>()))
                .Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951".ToLower())
                .Callback(PrepareClientToReturnQueuedItem);

            Mocker.GetMock<IDelugeProxy>()
                .Setup(s => s.AddTorrentFromFile(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<DelugeSettings>()))
                .Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951".ToLower())
                .Callback(PrepareClientToReturnQueuedItem);
        }

19 Source : DelugeFixture.cs
with GNU General Public License v3.0
from bonarr

protected virtual void GivenTorrents(List<DelugeTorrent> torrents)
        {
            if (torrents == null)
            {
                torrents = new List<DelugeTorrent>();
            }

            Mocker.GetMock<IDelugeProxy>()
                .Setup(s => s.GetTorrents(It.IsAny<DelugeSettings>()))
                .Returns(torrents.ToArray());
        }

19 Source : DelugeFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_return_status_with_outputdirs()
        {
            var configItems = new Dictionary<string, object>();

            configItems.Add("download_location", @"C:\Downloads\Downloading\deluge".AsOsAgnostic());
            configItems.Add("move_completed_path", @"C:\Downloads\Finished\deluge".AsOsAgnostic());
            configItems.Add("move_completed", true);

            Mocker.GetMock<IDelugeProxy>()
                .Setup(v => v.GetConfig(It.IsAny<DelugeSettings>()))
                .Returns(configItems);

            var result = Subject.GetStatus();

            result.IsLocalhost.Should().BeTrue();
            result.OutputRootFolders.Should().NotBeNull();
            result.OutputRootFolders.First().Should().Be(@"C:\Downloads\Finished\deluge".AsOsAgnostic());
        }

19 Source : SerialNumberProviderFixture.cs
with GNU General Public License v3.0
from bonarr

private void GivenValidResponse()
        {
            Mocker.GetMock<IDSMInfoProxy>()
                  .Setup(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
                  .Returns("serial");
        }

19 Source : SerialNumberProviderFixture.cs
with GNU General Public License v3.0
from bonarr

private void GivenInvalidResponse()
        {
            Mocker.GetMock<IDSMInfoProxy>()
                  .Setup(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
                  .Throws(new DownloadClientException("Serial response invalid"));
        }

19 Source : SerialNumberProviderFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_return_hashedserialnumber()
        {
            GivenValidResponse();

            var serial = Subject.GetSerialNumber(_settings);

            // This hash should remain the same for 'serial', so don't update the test if you change HashConverter, fix the code instead.
            serial.Should().Be("50DE66B735D30738618568294742FCF1DFA52A47");

            Mocker.GetMock<IDSMInfoProxy>()
                  .Verify(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()), Times.Once());
        }

19 Source : SerialNumberProviderFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_cache_serialnumber()
        {
            GivenValidResponse();

            var serial1 = Subject.GetSerialNumber(_settings);
            var serial2 = Subject.GetSerialNumber(_settings);

            serial2.Should().Be(serial1);

            Mocker.GetMock<IDSMInfoProxy>()
                  .Verify(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()), Times.Once());
        }

19 Source : SharedFolderResolverFixture.cs
with GNU General Public License v3.0
from bonarr

[SetUp]
        protected void Setup()
        {
            _sharedFolder = new OsPath("/myFolder");
            _physicalPath = new OsPath("/mnt/sda1/folder");
            _settings = new DownloadStationSettings();

            Mocker.GetMock<IFileStationProxy>()
                  .Setup(f => f.GetSharedFolderMapping(It.IsAny<string>(), It.IsAny<DownloadStationSettings>()))
                  .Throws(new DownloadClientException("There is no shared folder"));

            Mocker.GetMock<IFileStationProxy>()
                  .Setup(f => f.GetSharedFolderMapping(_sharedFolder.FullPath, It.IsAny<DownloadStationSettings>()))
                  .Returns(new SharedFolderMapping(_sharedFolder.FullPath, _physicalPath.FullPath));
        }

19 Source : SharedFolderResolverFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_return_valid_sharedfolder()
        {
            var mapping = Subject.RemapToFullPath(_sharedFolder, _settings, "abc");

            mapping.Should().Be(_physicalPath);

            Mocker.GetMock<IFileStationProxy>()
                  .Verify(f => f.GetSharedFolderMapping(It.IsAny<string>(), It.IsAny<DownloadStationSettings>()), Times.Once());
        }

19 Source : SharedFolderResolverFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_cache_mapping()
        {
            Subject.RemapToFullPath(_sharedFolder, _settings, "abc");
            Subject.RemapToFullPath(_sharedFolder, _settings, "abc");

            Mocker.GetMock<IFileStationProxy>()
                  .Verify(f => f.GetSharedFolderMapping(It.IsAny<string>(), It.IsAny<DownloadStationSettings>()), Times.Once());
        }

19 Source : TorrentDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

[SetUp]
        public void Setup()
        {
            _settings = new DownloadStationSettings()
            {
                Host = "127.0.0.1",
                Port = 5000,
                Username = "admin",
                Preplacedword = "preplaced"
            };

            Subject.Definition = new DownloadClientDefinition();
            Subject.Definition.Settings = _settings;

            _queued = new DownloadStationTask()
            {
                Id = "id1",
                Size = 1000,
                Status = DownloadStationTaskStatus.Waiting,
                Type = DownloadStationTaskType.BT.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", DownloadURL }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "0"},
                        { "speed_download", "0" }
                    }
                }
            };

            _completed = new DownloadStationTask()
            {
                Id = "id2",
                Size = 1000,
                Status = DownloadStationTaskStatus.Finished,
                Type = DownloadStationTaskType.BT.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", DownloadURL }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "1000"},
                        { "speed_download", "0" }
                    },
                }
            };

            _seeding = new DownloadStationTask()
            {
                Id = "id2",
                Size = 1000,
                Status = DownloadStationTaskStatus.Seeding,
                Type = DownloadStationTaskType.BT.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", DownloadURL }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "1000"},
                        { "speed_download", "0" }
                    }
                }
            };

            _downloading = new DownloadStationTask()
            {
                Id = "id3",
                Size = 1000,
                Status = DownloadStationTaskStatus.Downloading,
                Type = DownloadStationTaskType.BT.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", DownloadURL }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "100"},
                        { "speed_download", "50" }
                    }
                }
            };

            _failed = new DownloadStationTask()
            {
                Id = "id4",
                Size = 1000,
                Status = DownloadStationTaskStatus.Error,
                Type = DownloadStationTaskType.BT.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", DownloadURL }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "10"},
                        { "speed_download", "0" }
                    }
                }
            };

            _singleFile = new DownloadStationTask()
            {
                Id = "id5",
                Size = 1000,
                Status = DownloadStationTaskStatus.Seeding,
                Type = DownloadStationTaskType.BT.ToString(),
                Username = "admin",
                replacedle = "a.mkv",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", DownloadURL }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "1000"},
                        { "speed_download", "0" }
                    }
                }
            };

            _multipleFiles = new DownloadStationTask()
            {
                Id = "id6",
                Size = 1000,
                Status = DownloadStationTaskStatus.Seeding,
                Type = DownloadStationTaskType.BT.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", DownloadURL }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "1000"},
                        { "speed_download", "0" }
                    }
                }
            };

            _singleFileCompleted = new DownloadStationTask()
            {
                Id = "id6",
                Size = 1000,
                Status = DownloadStationTaskStatus.Finished,
                Type = DownloadStationTaskType.BT.ToString(),
                Username = "admin",
                replacedle = "a.mkv",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", DownloadURL }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "1000"},
                        { "speed_download", "0" }
                    }
                }
            };

            _multipleFilesCompleted = new DownloadStationTask()
            {
                Id = "id6",
                Size = 1000,
                Status = DownloadStationTaskStatus.Finished,
                Type = DownloadStationTaskType.BT.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", DownloadURL }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "1000"},
                        { "speed_download", "0" }
                    }
                }
            };

            Mocker.GetMock<ITorrentFileInfoReader>()
                  .Setup(s => s.GetHashFromTorrentFile(It.IsAny<byte[]>()))
                  .Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951");

            Mocker.GetMock<IHttpClient>()
                  .Setup(s => s.Get(It.IsAny<HttpRequest>()))
                  .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0]));

            _downloadStationConfigItems = new Dictionary<string, object>
            {
                { "default_destination", _defaultDestination },
            };

            Mocker.GetMock<IDownloadStationInfoProxy>()
              .Setup(v => v.GetConfig(It.IsAny<DownloadStationSettings>()))
              .Returns(_downloadStationConfigItems);
        }

19 Source : TorrentDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

protected void GivenSharedFolder()
        {
            Mocker.GetMock<ISharedFolderResolver>()
                  .Setup(s => s.RemapToFullPath(It.IsAny<OsPath>(), It.IsAny<DownloadStationSettings>(), It.IsAny<string>()))
                  .Returns<OsPath, DownloadStationSettings, string>((path, setttings, serial) => _physicalPath);
        }

19 Source : TorrentDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

protected void GivenSerialNumber()
        {
            Mocker.GetMock<ISerialNumberProvider>()
                .Setup(s => s.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
                .Returns(_serialNumber);
        }

19 Source : TorrentDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

protected virtual void GivenTasks(List<DownloadStationTask> torrents)
        {
            if (torrents == null)
            {
                torrents = new List<DownloadStationTask>();
            }

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Setup(s => s.GetTasks(It.IsAny<DownloadStationSettings>()))
                  .Returns(torrents);
        }

19 Source : TorrentDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

protected void GivenSuccessfulDownload()
        {
            Mocker.GetMock<IHttpClient>()
                  .Setup(s => s.Get(It.IsAny<HttpRequest>()))
                  .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[1000]));

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Setup(s => s.AddTaskFromUrl(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<DownloadStationSettings>()))
                  .Callback(PrepareClientToReturnQueuedItem);

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Setup(s => s.AddTaskFromData(It.IsAny<byte[]>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<DownloadStationSettings>()))
                  .Callback(PrepareClientToReturnQueuedItem);
        }

19 Source : TorrentDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Download_with_TvDirectory_should_force_directory()
        {
            GivenSerialNumber();
            GivenTvDirectory();
            GivenSuccessfulDownload();

            var remoteEpisode = CreateRemoteMovie();

            var id = Subject.Download(remoteEpisode);

            id.Should().NotBeNullOrEmpty();

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), _tvDirectory, It.IsAny<DownloadStationSettings>()), Times.Once());
        }

19 Source : TorrentDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Download_with_category_should_force_directory()
        {
            GivenSerialNumber();
            GivenTvCategory();
            GivenSuccessfulDownload();

            var remoteEpisode = CreateRemoteMovie();

            var id = Subject.Download(remoteEpisode);

            id.Should().NotBeNullOrEmpty();

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), $"{_defaultDestination}/{_category}", It.IsAny<DownloadStationSettings>()), Times.Once());
        }

19 Source : TorrentDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Download_without_TvDirectory_and_Category_should_use_default()
        {
            GivenSerialNumber();
            GivenSuccessfulDownload();

            var remoteEpisode = CreateRemoteMovie();

            var id = Subject.Download(remoteEpisode);

            id.Should().NotBeNullOrEmpty();

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, It.IsAny<DownloadStationSettings>()), Times.Once());
        }

19 Source : TorrentDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Gereplacedems_should_throw_if_shared_folder_resolve_fails()
        {
            Mocker.GetMock<ISharedFolderResolver>()
                  .Setup(s => s.RemapToFullPath(It.IsAny<OsPath>(), It.IsAny<DownloadStationSettings>(), It.IsAny<string>()))
                  .Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));

            GivenSerialNumber();
            GivenAllKindOfTasks();

            replacedert.Throws(Is.InstanceOf<Exception>(), () => Subject.Gereplacedems());
            ExceptionVerification.ExpectedErrors(0);
        }

19 Source : TorrentDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number()
        {
            var remoteEpisode = CreateRemoteMovie();

            Mocker.GetMock<ISerialNumberProvider>()
                  .Setup(s => s.GetSerialNumber(_settings))
                  .Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));

            replacedert.Throws(Is.InstanceOf<Exception>(), () => Subject.Download(remoteEpisode));

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, _settings), Times.Never());
        }

19 Source : UsenetDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

[SetUp]
        public void Setup()
        {
            _remoteEpisode = CreateRemoteMovie();

            _settings = new DownloadStationSettings()
            {
                Host = "127.0.0.1",
                Port = 5000,
                Username = "admin",
                Preplacedword = "preplaced"
            };

            Subject.Definition = new DownloadClientDefinition();
            Subject.Definition.Settings = _settings;

            _queued = new DownloadStationTask()
            {
                Id = "id1",
                Size = 1000,
                Status = DownloadStationTaskStatus.Waiting,
                Type = DownloadStationTaskType.NZB.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.replacedle) + ".nzb" }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "0"},
                        { "speed_download", "0" }
                    }
                }
            };

            _completed = new DownloadStationTask()
            {
                Id = "id2",
                Size = 1000,
                Status = DownloadStationTaskStatus.Finished,
                Type = DownloadStationTaskType.NZB.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.replacedle) + ".nzb" }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "1000"},
                        { "speed_download", "0" }
                    },
                }
            };

            _seeding = new DownloadStationTask()
            {
                Id = "id2",
                Size = 1000,
                Status = DownloadStationTaskStatus.Seeding,
                Type = DownloadStationTaskType.NZB.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.replacedle) + ".nzb" }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "1000"},
                        { "speed_download", "0" }
                    }
                }
            };

            _downloading = new DownloadStationTask()
            {
                Id = "id3",
                Size = 1000,
                Status = DownloadStationTaskStatus.Downloading,
                Type = DownloadStationTaskType.NZB.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.replacedle) + ".nzb" }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "100"},
                        { "speed_download", "50" }
                    }
                }
            };

            _failed = new DownloadStationTask()
            {
                Id = "id4",
                Size = 1000,
                Status = DownloadStationTaskStatus.Error,
                Type = DownloadStationTaskType.NZB.ToString(),
                Username = "admin",
                replacedle = "replacedle",
                Additional = new DownloadStationTaskAdditional
                {
                    Detail = new Dictionary<string, string>
                    {
                        { "destination","shared/folder" },
                        { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.replacedle) + ".nzb" }
                    },
                    Transfer = new Dictionary<string, string>
                    {
                        { "size_downloaded", "10"},
                        { "speed_download", "0" }
                    }
                }
            };

            Mocker.GetMock<IHttpClient>()
                  .Setup(s => s.Get(It.IsAny<HttpRequest>()))
                  .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0]));

            _downloadStationConfigItems = new Dictionary<string, object>
            {
                { "default_destination", _defaultDestination },
            };

            Mocker.GetMock<IDownloadStationInfoProxy>()
              .Setup(v => v.GetConfig(It.IsAny<DownloadStationSettings>()))
              .Returns(_downloadStationConfigItems);
        }

19 Source : UsenetDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

protected virtual void GivenTasks(List<DownloadStationTask> nzbs)
        {
            if (nzbs == null)
            {
                nzbs = new List<DownloadStationTask>();
            }

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Setup(s => s.GetTasks(It.IsAny<DownloadStationSettings>()))
                  .Returns(nzbs);
        }

19 Source : UsenetDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

protected void GivenSuccessfulDownload()
        {/*
            Mocker.GetMock<IHttpClient>()
                  .Setup(s => s.Get(It.IsAny<HttpRequest>()))
                  .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[1000]));
            */

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Setup(s => s.AddTaskFromData(It.IsAny<byte[]>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<DownloadStationSettings>()))
                  .Callback(PrepareClientToReturnQueuedItem);
        }

19 Source : UsenetDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Download_with_TvDirectory_should_force_directory()
        {
            GivenSerialNumber();
            GivenTvDirectory();
            GivenSuccessfulDownload();

            var remoteEpisode = CreateRemoteMovie();

            var id = Subject.Download(remoteEpisode);

            id.Should().NotBeNullOrEmpty();

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Verify(v => v.AddTaskFromData(It.IsAny<byte[]>(), It.IsAny<string>(), _tvDirectory, It.IsAny<DownloadStationSettings>()), Times.Once());
        }

19 Source : UsenetDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Download_with_category_should_force_directory()
        {
            GivenSerialNumber();
            GivenTvCategory();
            GivenSuccessfulDownload();

            var remoteEpisode = CreateRemoteMovie();

            var id = Subject.Download(remoteEpisode);

            id.Should().NotBeNullOrEmpty();

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Verify(v => v.AddTaskFromData(It.IsAny<byte[]>(), It.IsAny<string>(), $"{_defaultDestination}/{_category}", It.IsAny<DownloadStationSettings>()), Times.Once());
        }

19 Source : UsenetDownloadStationFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Download_without_TvDirectory_and_Category_should_use_default()
        {
            GivenSerialNumber();
            GivenSuccessfulDownload();

            var remoteEpisode = CreateRemoteMovie();

            var id = Subject.Download(remoteEpisode);

            id.Should().NotBeNullOrEmpty();

            Mocker.GetMock<IDownloadStationTaskProxy>()
                  .Verify(v => v.AddTaskFromData(It.IsAny<byte[]>(), It.IsAny<string>(), null, It.IsAny<DownloadStationSettings>()), Times.Once());
        }

19 Source : HadoukenFixture.cs
with GNU General Public License v3.0
from bonarr

[SetUp]
        public void Setup()
        {
            Subject.Definition = new DownloadClientDefinition();
            Subject.Definition.Settings = new HadoukenSettings();

            _queued = new HadoukenTorrent
            {
                InfoHash = "HASH",
                IsFinished = false,
                State = HadoukenTorrentState.QueuedForChecking,
                Name = _replacedle,
                TotalSize = 1000,
                DownloadedBytes = 0,
                Progress = 0.0,
                SavePath = "somepath",
                Label = "radarr"
            };

            _downloading = new HadoukenTorrent
            {
                InfoHash = "HASH",
                IsFinished = false,
                State = HadoukenTorrentState.Downloading,
                Name = _replacedle,
                TotalSize = 1000,
                DownloadedBytes = 100,
                Progress = 10.0,
                SavePath = "somepath",
                Label = "radarr"
            };

            _failed = new HadoukenTorrent
            {
                InfoHash = "HASH",
                IsFinished = false,
                State = HadoukenTorrentState.Downloading,
                Error = "some error",
                Name = _replacedle,
                TotalSize = 1000,
                DownloadedBytes = 100,
                Progress = 10.0,
                SavePath = "somepath",
                Label = "radarr"
            };

            _completed = new HadoukenTorrent
            {
                InfoHash = "HASH",
                IsFinished = true,
                State = HadoukenTorrentState.Paused,
                Name = _replacedle,
                TotalSize = 1000,
                DownloadedBytes = 1000,
                Progress = 100.0,
                SavePath = "somepath",
                Label = "radarr"
            };

            Mocker.GetMock<ITorrentFileInfoReader>()
                  .Setup(s => s.GetHashFromTorrentFile(It.IsAny<Byte[]>()))
                  .Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951");

            Mocker.GetMock<IHttpClient>()
                  .Setup(s => s.Get(It.IsAny<HttpRequest>()))
                  .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0]));
        }

19 Source : HadoukenFixture.cs
with GNU General Public License v3.0
from bonarr

protected void GivenFailedDownload()
        {
            Mocker.GetMock<IHadoukenProxy>()
                .Setup(s => s.AddTorrentUri(It.IsAny<HadoukenSettings>(), It.IsAny<string>()))
                .Throws<InvalidOperationException>();

            Mocker.GetMock<IHadoukenProxy>()
                .Setup(s => s.AddTorrentFile(It.IsAny<HadoukenSettings>(), It.IsAny<byte[]>()))
                .Throws<InvalidOperationException>();
        }

19 Source : HadoukenFixture.cs
with GNU General Public License v3.0
from bonarr

protected void GivenSuccessfulDownload()
        {
            Mocker.GetMock<IHttpClient>()
                  .Setup(s => s.Get(It.IsAny<HttpRequest>()))
                  .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[1000]));

            Mocker.GetMock<IHadoukenProxy>()
                .Setup(s => s.AddTorrentUri(It.IsAny<HadoukenSettings>(), It.IsAny<string>()))
                .Callback(PrepareClientToReturnQueuedItem);

            Mocker.GetMock<IHadoukenProxy>()
                .Setup(s => s.AddTorrentFile(It.IsAny<HadoukenSettings>(), It.IsAny<byte[]>()))
                .Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951".ToLower())
                .Callback(PrepareClientToReturnQueuedItem);
        }

19 Source : HadoukenFixture.cs
with GNU General Public License v3.0
from bonarr

protected virtual void GivenTorrents(List<HadoukenTorrent> torrents)
        {
            if (torrents == null)
            {
                torrents = new List<HadoukenTorrent>();
            }

            Mocker.GetMock<IHadoukenProxy>()
                .Setup(s => s.GetTorrents(It.IsAny<HadoukenSettings>()))
                .Returns(torrents.ToArray());
        }

19 Source : HadoukenFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void should_return_status_with_outputdirs()
        {
            var configItems = new Dictionary<String, Object>();

            configItems.Add("bittorrent.defaultSavePath", @"C:\Downloads\Downloading\deluge".AsOsAgnostic());

            Mocker.GetMock<IHadoukenProxy>()
                .Setup(v => v.GetConfig(It.IsAny<HadoukenSettings>()))
                .Returns(configItems);

            var result = Subject.GetStatus();

            result.IsLocalhost.Should().BeTrue();
            result.OutputRootFolders.Should().NotBeNull();
            result.OutputRootFolders.First().Should().Be(@"C:\Downloads\Downloading\deluge".AsOsAgnostic());
        }

19 Source : HadoukenFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Gereplacedems_should_return_torrents_with_DownloadId_uppercase()
        {
            var torrent = new HadoukenTorrent
            {
                InfoHash = "hash",
                IsFinished = true,
                State = HadoukenTorrentState.Paused,
                Name = _replacedle,
                TotalSize = 1000,
                DownloadedBytes = 1000,
                Progress = 100.0,
                SavePath = "somepath",
                Label = "radarr"
            };

            var torrents = new HadoukenTorrent[] { torrent };
            Mocker.GetMock<IHadoukenProxy>()
                .Setup(v => v.GetTorrents(It.IsAny<HadoukenSettings>()))
                .Returns(torrents);

            var result = Subject.Gereplacedems();
            var downloadItem = result.First();

            downloadItem.DownloadId.Should().Be("HASH");
        }

19 Source : HadoukenFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Gereplacedems_should_ignore_torrents_with_a_different_category()
        {
            var torrent = new HadoukenTorrent
            {
                InfoHash = "hash",
                IsFinished = true,
                State = HadoukenTorrentState.Paused,
                Name = _replacedle,
                TotalSize = 1000,
                DownloadedBytes = 1000,
                Progress = 100.0,
                SavePath = "somepath",
                Label = "radarr-other"
            };

            var torrents = new HadoukenTorrent[] { torrent };
            Mocker.GetMock<IHadoukenProxy>()
                .Setup(v => v.GetTorrents(It.IsAny<HadoukenSettings>()))
                .Returns(torrents);

            Subject.Gereplacedems().Should().BeEmpty();
        }

19 Source : HadoukenFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Download_from_magnet_link_should_return_hash_uppercase()
        {
            var remoteMovie = CreateRemoteMovie();

            remoteMovie.Release.DownloadUrl = "magnet:?xt=urn:btih:a45129e59d8750f9da982f53552b1e4f0457ee9f";

            Mocker.GetMock<IHadoukenProxy>()
               .Setup(v => v.AddTorrentUri(It.IsAny<HadoukenSettings>(), It.IsAny<string>()));

            var result = Subject.Download(remoteMovie);

            replacedert.IsFalse(result.Any(c => char.IsLower(c)));
        }

19 Source : HadoukenFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Download_from_torrent_file_should_return_hash_uppercase()
        {
            var remoteMovie = CreateRemoteMovie();

            Mocker.GetMock<IHadoukenProxy>()
               .Setup(v => v.AddTorrentFile(It.IsAny<HadoukenSettings>(), It.IsAny<byte[]>()))
               .Returns("hash");

            var result = Subject.Download(remoteMovie);

            replacedert.IsFalse(result.Any(c => char.IsLower(c)));
        }

19 Source : HadoukenFixture.cs
with GNU General Public License v3.0
from bonarr

[Test]
        public void Test_should_return_validation_failure_for_old_hadouken()
        {
            var systemInfo = new HadoukenSystemInfo()
            {
                Versions = new Dictionary<string, string>() { { "hadouken", "5.0.0.0" } }
            };

            Mocker.GetMock<IHadoukenProxy>()
               .Setup(v => v.GetSystemInfo(It.IsAny<HadoukenSettings>()))
               .Returns(systemInfo);

            var result = Subject.Test();

            result.Errors.First().ErrorMessage.Should().Be("Old Hadouken client with unsupported API, need 5.1 or higher");
        }

19 Source : NzbgetFixture.cs
with GNU General Public License v3.0
from bonarr

[SetUp]
        public void Setup()
        {
            Subject.Definition = new DownloadClientDefinition();
            Subject.Definition.Settings = new NzbgetSettings
                                          {
                                              Host = "127.0.0.1",
                                              Port = 2222,
                                              Username = "admin",
                                              Preplacedword = "preplaced",
                                              TvCategory = "tv",
                                              RecentTvPriority = (int)NzbgetPriority.High
                                          };

            _queued = new NzbgetQueueItem
                {
                    FileSizeLo = 1000,
                    RemainingSizeLo = 10,
                    Category = "tv",
                    NzbName = "Droned.1998.1080p.WEB-DL-DRONE",
                    Parameters = new List<NzbgetParameter> { new NzbgetParameter { Name = "drone", Value = "id" } }
                };

            _failed = new NzbgetHistoryItem
                {
                    FileSizeLo = 1000,
                    Category = "tv",
                    Name = "Droned.1998.1080p.WEB-DL-DRONE",
                    DestDir = "somedirectory",
                    Parameters = new List<NzbgetParameter> { new NzbgetParameter { Name = "drone", Value = "id" } },
                    ParStatus = "Some Error",
                    UnpackStatus = "NONE",
                    MoveStatus = "NONE",
                    ScriptStatus = "NONE",
                    DeleteStatus = "NONE",
                    MarkStatus = "NONE"
                };

            _completed = new NzbgetHistoryItem
                {
                    FileSizeLo = 1000,
                    Category = "tv",
                    Name = "Droned.1998.1080p.WEB-DL-DRONE",
                    DestDir = "/remote/mount/tv/Droned.1998.1080p.WEB-DL-DRONE",
                    Parameters = new List<NzbgetParameter> { new NzbgetParameter { Name = "drone", Value = "id" } },
                    ParStatus = "SUCCESS",
                    UnpackStatus = "NONE",
                    MoveStatus = "SUCCESS",
                    ScriptStatus = "NONE",
                    DeleteStatus = "NONE",
                    MarkStatus = "NONE"
                };

            Mocker.GetMock<INzbgetProxy>()
                .Setup(s => s.GetGlobalStatus(It.IsAny<NzbgetSettings>()))
                .Returns(new NzbgetGlobalStatus
                {
                    DownloadRate = 7000000
                });

            var configItems = new Dictionary<string, string>();
            configItems.Add("Category1.Name", "tv");
            configItems.Add("Category1.DestDir", @"/remote/mount/tv");

            Mocker.GetMock<INzbgetProxy>()
                .Setup(v => v.GetConfig(It.IsAny<NzbgetSettings>()))
                .Returns(configItems);
        }

19 Source : NzbgetFixture.cs
with GNU General Public License v3.0
from bonarr

protected void GivenFailedDownload()
        {
            Mocker.GetMock<INzbgetProxy>()
                .Setup(s => s.DownloadNzb(It.IsAny<byte[]>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<bool>(), It.IsAny<NzbgetSettings>()))
                .Returns((string)null);
        }

See More Examples