mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
* First fixing of tests. * Updated more tests. * Fix some tests * Fix all prioritization tests. And add new for preferred words. * Updated CompletedDownloadservice tests * Fixed a lot of tests * Fixed all indexer requests. We should add more for the indexers we added. To lazy for that though ¯\_(ツ)_/¯ * Fixed organizer tests. Should probably be also updated to incorporate our newly added tags. * Fix notification tests. * Fixed update test for osx * Fixed a few more tests. * Fixed some more tests. * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update activity.less * Update appveyor.yml * Update appveyor.yml * Update CommonVersionInfo.cs * Update build-appveyor.cake Let's hope this works. * Update CommonVersionInfo.cs Just to kickstart appveyor * Fixed a few tests * Just ignore those tests. * Fixed more tests. * First steps in fixing Core.Test.Download.DownloadApprovedFixture * Fix most DownloadApprovedFixture tests * Fixed something. * Fixed a few more tests. * Fixed pending release tests. * All Core tests are now fixed. * Fixed the last tests :) * Fixed Download Station Tests. * Fixed Vuze and Transmission default settings which caused the tests to fail. * Fix most tests. * Fix RootFolder tests. * Fixed last tests
90 lines
2.8 KiB
C#
90 lines
2.8 KiB
C#
using System.Net;
|
|
using FluentAssertions;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Common.Disk;
|
|
using NzbDrone.Common.Http;
|
|
using NzbDrone.Core.MediaCover;
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
namespace NzbDrone.Core.Test.MediaCoverTests
|
|
{
|
|
[TestFixture]
|
|
public class CoverAlreadyExistsSpecificationFixture : CoreTest<CoverAlreadyExistsSpecification>
|
|
{
|
|
private HttpResponse _httpResponse;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
_httpResponse = new HttpResponse(null, new HttpHeader(), "", HttpStatusCode.OK);
|
|
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetFileSize(It.IsAny<string>())).Returns(100);
|
|
Mocker.GetMock<IHttpClient>().Setup(c => c.Head(It.IsAny<HttpRequest>())).Returns(_httpResponse);
|
|
|
|
}
|
|
|
|
|
|
private void GivenFileExistsOnDisk()
|
|
{
|
|
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(It.IsAny<string>())).Returns(true);
|
|
}
|
|
|
|
|
|
private void GivenExistingFileSize(long bytes)
|
|
{
|
|
GivenFileExistsOnDisk();
|
|
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetFileSize(It.IsAny<string>())).Returns(bytes);
|
|
|
|
}
|
|
|
|
private void GivenImageFileCorrupt(bool corrupt)
|
|
{
|
|
GivenFileExistsOnDisk();
|
|
Mocker.GetMock<IDiskProvider>()
|
|
.Setup(c => c.IsValidGDIPlusImage(It.IsAny<string>()))
|
|
.Returns(!corrupt);
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void should_return_false_if_file_not_exists()
|
|
{
|
|
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse();
|
|
}
|
|
|
|
[Test]
|
|
public void should_return_false_if_file_exists_but_diffrent_size()
|
|
{
|
|
GivenExistingFileSize(100);
|
|
_httpResponse.Headers.ContentLength = 200;
|
|
|
|
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse();
|
|
}
|
|
|
|
[Test]
|
|
public void should_return_false_if_file_exists_and_same_size_and_corrupt()
|
|
{
|
|
GivenExistingFileSize(100);
|
|
GivenImageFileCorrupt(true);
|
|
_httpResponse.Headers.ContentLength = 100;
|
|
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse();
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void should_return_true_if_file_exists_and_same_size_and_not_corrupt()
|
|
{
|
|
GivenExistingFileSize(100);
|
|
GivenImageFileCorrupt(false);
|
|
_httpResponse.Headers.ContentLength = 100;
|
|
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeTrue();
|
|
}
|
|
|
|
[Test]
|
|
public void should_return_true_if_there_is_no_size_header_and_file_exist()
|
|
{
|
|
GivenExistingFileSize(100);
|
|
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse();
|
|
}
|
|
}
|
|
} |