2013-06-13 01:37:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
2013-03-04 05:53:02 +00:00
|
|
|
|
using NzbDrone.Common;
|
2013-06-28 00:04:52 +00:00
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-03-04 05:53:02 +00:00
|
|
|
|
using NzbDrone.Core.MediaCover;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2013-06-13 01:37:05 +00:00
|
|
|
|
using System.Linq;
|
2013-03-04 05:53:02 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.MediaCoverTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class MediaCoverServiceFixture : CoreTest<MediaCoverService>
|
|
|
|
|
{
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2013-08-13 05:08:37 +00:00
|
|
|
|
Mocker.SetConstant<IAppFolderInfo>(new AppFolderInfo(new DiskProvider(), Mocker.Resolve<IStartupArguments>()));
|
2013-06-13 01:37:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_convert_trakts_urls_to_local()
|
|
|
|
|
{
|
|
|
|
|
var covers = new List<MediaCover.MediaCover>
|
|
|
|
|
{
|
|
|
|
|
new MediaCover.MediaCover {CoverType = MediaCoverTypes.Banner}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetLastFileWrite(It.IsAny<string>()))
|
|
|
|
|
.Returns(new DateTime(1234));
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(It.IsAny<string>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
Subject.ConvertToLocalUrls(12, covers);
|
|
|
|
|
|
|
|
|
|
|
2013-07-24 06:26:10 +00:00
|
|
|
|
covers.Single().Url.Should().Be("/MediaCover/12/banner.jpg?lastWrite=1234");
|
2013-06-13 01:37:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_convert_trakts_urls_to_local_without_time_if_file_doesnt_exist()
|
|
|
|
|
{
|
|
|
|
|
var covers = new List<MediaCover.MediaCover>
|
|
|
|
|
{
|
|
|
|
|
new MediaCover.MediaCover {CoverType = MediaCoverTypes.Banner}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.ConvertToLocalUrls(12, covers);
|
|
|
|
|
|
|
|
|
|
|
2013-07-24 06:26:10 +00:00
|
|
|
|
covers.Single().Url.Should().Be("/MediaCover/12/banner.jpg");
|
2013-03-04 05:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|