Merge branch 'master' of git://github.com/kayone/NzbDrone

pull/4/head
Mark McDowall 14 years ago
commit f946eeed42

@ -53,7 +53,7 @@ namespace NzbDrone.Core.Test
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries); mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
//Assert //Assert
var actualCount = mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).Count; var actualCount = mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList().Count;
mocker.GetMock<TvDbProvider>().VerifyAll(); mocker.GetMock<TvDbProvider>().VerifyAll();
actualCount.Should().Be(episodeCount); actualCount.Should().Be(episodeCount);
mocker.VerifyAllMocks(); mocker.VerifyAllMocks();

@ -29,6 +29,7 @@ namespace NzbDrone.Core.Test
base.Setup(); base.Setup();
int currentFileId = 0;
foreach (var _seriesId in seriesIds) foreach (var _seriesId in seriesIds)
{ {
@ -44,27 +45,38 @@ namespace NzbDrone.Core.Test
{ {
for (int i = 1; i <= Episodes_Per_Season; i++) for (int i = 1; i <= Episodes_Per_Season; i++)
{ {
var epFileId = 0;
if (i < 10)
{
var epFile = Builder<EpisodeFile>.CreateNew()
.With(e => e.SeriesId = seriesId)
.With(e => e.SeriesId = seriesId)
.And(e => e.SeasonNumber = _seasonNumber)
.And(e => e.Path = Guid.NewGuid().ToString())
.Build();
files.Add(epFile);
currentFileId++;
epFileId = currentFileId;
}
var episode = Builder<Episode>.CreateNew() var episode = Builder<Episode>.CreateNew()
.With(e => e.SeriesId = seriesId) .With(e => e.SeriesId = seriesId)
.And(e => e.SeasonNumber = _seasonNumber) .And(e => e.SeasonNumber = _seasonNumber)
.And(e => e.EpisodeNumber = i) .And(e => e.EpisodeNumber = i)
.And(e => e.Ignored = false) .And(e => e.Ignored = false)
.And(e => e.TvDbEpisodeId = episodes.Count + 1) .And(e => e.TvDbEpisodeId = episodes.Count + 1)
.And(e => e.EpisodeFileId = epFileId)
.And(e => e.AirDate = DateTime.Today.AddDays(-20)) .And(e => e.AirDate = DateTime.Today.AddDays(-20))
.Build(); .Build();
episodes.Add(episode); episodes.Add(episode);
if (i < 10)
{
var epFile = Builder<EpisodeFile>.CreateNew()
.With(e => e.SeriesId = seriesId)
.And(e => e.SeasonNumber = _seasonNumber)
.And(e => e.Path = Guid.NewGuid().ToString())
.Build();
files.Add(epFile);
}
} }
} }
@ -72,7 +84,6 @@ namespace NzbDrone.Core.Test
repo.AddMany(episodes); repo.AddMany(episodes);
repo.AddMany(files); repo.AddMany(files);
} }
@ -177,5 +188,36 @@ namespace NzbDrone.Core.Test
Console.WriteLine("Took " + sw.Elapsed); Console.WriteLine("Took " + sw.Elapsed);
} }
[Test]
public void get_episode_file_count_x10()
{
var mocker = new AutoMoq.AutoMoqer();
mocker.SetConstant(repo);
mocker.SetConstant(mocker.Resolve<EpisodeProvider>());
var provider = mocker.Resolve<MediaFileProvider>();
Thread.Sleep(1000);
var random = new Random();
Console.WriteLine("Starting Test");
var sw = Stopwatch.StartNew();
for (int i = 0; i < 100; i++)
{
var result = provider.GetEpisodeFilesCount(random.Next(1, 10));
result.Item1.Should().NotBe(0);
result.Item2.Should().NotBe(0);
}
sw.Stop();
Console.WriteLine("Took " + sw.Elapsed);
}
} }
} }

@ -191,10 +191,10 @@ namespace NzbDrone.Core.Providers
{ {
var allEpisodes = _episodeProvider.GetEpisodeBySeries(seriesId); var allEpisodes = _episodeProvider.GetEpisodeBySeries(seriesId);
var episodeTotal = allEpisodes.Where(e => !e.Ignored && e.AirDate <= DateTime.Today && e.AirDate.Year > 1900).ToList(); var episodeTotal = allEpisodes.Where(e => !e.Ignored && e.AirDate <= DateTime.Today && e.AirDate.Year > 1900);
var avilableEpisodes = episodeTotal.Where(e => e.EpisodeFileId > 0); var avilableEpisodes = episodeTotal.Where(e => e.EpisodeFileId > 0);
return new Tuple<int, int>(avilableEpisodes.Count(), episodeTotal.Count); return new Tuple<int, int>(avilableEpisodes.Count(), episodeTotal.Count());
} }
private List<string> GetMediaFileList(string path) private List<string> GetMediaFileList(string path)

@ -11,6 +11,7 @@
<add key="UnobtrusiveJavaScriptEnabled" value="false" /> <add key="UnobtrusiveJavaScriptEnabled" value="false" />
</appSettings> </appSettings>
<system.web> <system.web>
<trust level="Full" originUrl=".*" />
<compilation debug="true" targetFramework="4.0"> <compilation debug="true" targetFramework="4.0">
<assemblies> <assemblies>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

Loading…
Cancel
Save