using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Notifications.Xbmc; using NzbDrone.Core.Notifications.Xbmc.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Movies; namespace NzbDrone.Core.Test.NotificationTests.Xbmc { [TestFixture] public class GetMoviePathFixture : CoreTest { private const string IMDB_ID = "tt67890"; private XbmcSettings _settings; private Movie _movie; private List _xbmcMovies; [SetUp] public void Setup() { _settings = Builder.CreateNew() .Build(); _xbmcMovies = Builder.CreateListOfSize(3) .All() .With(s => s.ImdbNumber = "tt00000") .TheFirst(1) .With(s => s.ImdbNumber = IMDB_ID) .Build() .ToList(); Mocker.GetMock() .Setup(s => s.GetMovies(_settings)) .Returns(_xbmcMovies); } private void GivenMatchingImdbId() { _movie = new Movie { ImdbId = IMDB_ID, Title = "Movie" }; } private void GivenMatchingTitle() { _movie = new Movie { ImdbId = "tt01000", Title = _xbmcMovies.First().Label }; } private void GivenMatchingMovie() { _movie = new Movie { ImdbId = "tt01000", Title = "Does not exist" }; } [Test] public void should_return_null_when_movie_is_not_found() { GivenMatchingMovie(); Subject.GetMoviePath(_settings, _movie).Should().BeNull(); } [Test] public void should_return_path_when_tvdbId_matches() { GivenMatchingImdbId(); Subject.GetMoviePath(_settings, _movie).Should().Be(_xbmcMovies.First().File); } [Test] public void should_return_path_when_title_matches() { GivenMatchingTitle(); Subject.GetMoviePath(_settings, _movie).Should().Be(_xbmcMovies.First().File); } } }