|
|
@ -70,84 +70,5 @@ namespace NzbDrone.Core.Test.HistoryTests
|
|
|
|
|
|
|
|
|
|
|
|
downloadHistory.Should().HaveCount(1);
|
|
|
|
downloadHistory.Should().HaveCount(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_get_movie_history()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var historyMovie1 = Builder<MovieHistory>.CreateNew()
|
|
|
|
|
|
|
|
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
|
|
|
|
|
|
|
.With(c => c.Languages = new List<Language> { Language.English })
|
|
|
|
|
|
|
|
.With(c => c.MovieId = 12)
|
|
|
|
|
|
|
|
.With(c => c.EventType = MovieHistoryEventType.Grabbed)
|
|
|
|
|
|
|
|
.BuildNew();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var historyMovie2 = Builder<MovieHistory>.CreateNew()
|
|
|
|
|
|
|
|
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
|
|
|
|
|
|
|
.With(c => c.Languages = new List<Language> { Language.English })
|
|
|
|
|
|
|
|
.With(c => c.MovieId = 13)
|
|
|
|
|
|
|
|
.With(c => c.EventType = MovieHistoryEventType.Grabbed)
|
|
|
|
|
|
|
|
.BuildNew();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Insert(historyMovie1);
|
|
|
|
|
|
|
|
Subject.Insert(historyMovie2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var movieHistory = Subject.GetByMovieId(12, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
movieHistory.Should().HaveCount(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_sort_movie_history_by_date()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var historyFirst = Builder<MovieHistory>.CreateNew()
|
|
|
|
|
|
|
|
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
|
|
|
|
|
|
|
.With(c => c.Languages = new List<Language> { Language.English })
|
|
|
|
|
|
|
|
.With(c => c.MovieId = 12)
|
|
|
|
|
|
|
|
.With(c => c.EventType = MovieHistoryEventType.MovieFileRenamed)
|
|
|
|
|
|
|
|
.With(c => c.Date = DateTime.UtcNow)
|
|
|
|
|
|
|
|
.BuildNew();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var historySecond = Builder<MovieHistory>.CreateNew()
|
|
|
|
|
|
|
|
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
|
|
|
|
|
|
|
.With(c => c.Languages = new List<Language> { Language.English })
|
|
|
|
|
|
|
|
.With(c => c.MovieId = 12)
|
|
|
|
|
|
|
|
.With(c => c.EventType = MovieHistoryEventType.Grabbed)
|
|
|
|
|
|
|
|
.With(c => c.Date = DateTime.UtcNow.AddMinutes(10))
|
|
|
|
|
|
|
|
.BuildNew();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Insert(historyFirst);
|
|
|
|
|
|
|
|
Subject.Insert(historySecond);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var movieHistory = Subject.GetByMovieId(12, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
movieHistory.Should().HaveCount(2);
|
|
|
|
|
|
|
|
movieHistory.First().EventType.Should().Be(MovieHistoryEventType.Grabbed);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_delete_history_items_by_movieId()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var items = Builder<MovieHistory>.CreateListOfSize(5)
|
|
|
|
|
|
|
|
.TheFirst(1)
|
|
|
|
|
|
|
|
.With(c => c.MovieId = _movie2.Id)
|
|
|
|
|
|
|
|
.TheRest()
|
|
|
|
|
|
|
|
.With(c => c.MovieId = _movie1.Id)
|
|
|
|
|
|
|
|
.All()
|
|
|
|
|
|
|
|
.With(c => c.Id = 0)
|
|
|
|
|
|
|
|
.With(c => c.Quality = new QualityModel(Quality.Bluray1080p))
|
|
|
|
|
|
|
|
.With(c => c.Languages = new List<Language> { Language.English })
|
|
|
|
|
|
|
|
.With(c => c.EventType = MovieHistoryEventType.Grabbed)
|
|
|
|
|
|
|
|
.BuildListOfNew();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Db.InsertMany(items);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.DeleteForMovies(new List<int> { _movie1.Id });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var removedItems = Subject.GetByMovieId(_movie1.Id, null);
|
|
|
|
|
|
|
|
var nonRemovedItems = Subject.GetByMovieId(_movie2.Id, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
removedItems.Should().HaveCount(0);
|
|
|
|
|
|
|
|
nonRemovedItems.Should().HaveCount(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|