public void should_return_failure_if_blocked_list()
        {
            var fetchResult = new ImportListFetchResult();

            GivenList(1, true, true, fetchResult);
            GivenBlockedList(1);

            var listResult = Subject.Fetch();

            listResult.AnyFailure.Should().BeTrue();
        }
        public void should_return_failure_if_single_list_fails()
        {
            var fetchResult = new ImportListFetchResult {
                Movies = _listMovies, AnyFailure = true
            };

            GivenList(1, true, true, fetchResult);

            var listResult = Subject.Fetch();

            listResult.AnyFailure.Should().BeTrue();
        }
        public void should_not_store_movies_if_list_fails()
        {
            var listId      = 1;
            var fetchResult = new ImportListFetchResult {
                Movies = _listMovies, AnyFailure = true
            };

            GivenList(listId, true, true, fetchResult);

            var listResult = Subject.Fetch();

            listResult.AnyFailure.Should().BeTrue();

            Mocker.GetMock <IImportListMovieService>()
            .Verify(v => v.SyncMoviesForList(It.IsAny <List <ImportListMovie> >(), listId), Times.Never());
        }
        public void should_return_failure_if_one_blocked_list_one_good_list()
        {
            var fetchResult1 = new ImportListFetchResult();

            GivenList(1, true, true, fetchResult1);
            GivenBlockedList(1);

            var fetchResult2 = new ImportListFetchResult {
                Movies = _listMovies, AnyFailure = true
            };

            GivenList(2, true, true, fetchResult2);

            var listResult = Subject.Fetch();

            listResult.AnyFailure.Should().BeTrue();
        }
        public void should_return_all_results_for_all_lists()
        {
            var passedListId = 1;
            var fetchResult1 = new ImportListFetchResult {
                Movies = _listMovies, AnyFailure = false
            };

            GivenList(passedListId, true, true, fetchResult1);
            var failedListId = 2;
            var fetchResult2 = new ImportListFetchResult {
                Movies = _listMovies, AnyFailure = false
            };

            GivenList(failedListId, true, true, fetchResult2);

            var listResult = Subject.Fetch();

            listResult.AnyFailure.Should().BeFalse();
            listResult.Movies.Count.Should().Be(10);
        }
        public void should_only_store_movies_for_lists_that_dont_fail()
        {
            var passedListId = 1;
            var fetchResult1 = new ImportListFetchResult {
                Movies = _listMovies, AnyFailure = false
            };

            GivenList(passedListId, true, true, fetchResult1);
            var failedListId = 2;
            var fetchResult2 = new ImportListFetchResult {
                Movies = _listMovies, AnyFailure = true
            };

            GivenList(failedListId, true, true, fetchResult2);

            var listResult = Subject.Fetch();

            listResult.AnyFailure.Should().BeTrue();

            Mocker.GetMock <IImportListMovieService>()
            .Verify(v => v.SyncMoviesForList(It.IsAny <List <ImportListMovie> >(), passedListId), Times.Once());
        }
Exemplo n.º 7
0
        public void Setup()
        {
            _importLists = new List <IImportList>();

            _list1Movies = Builder <ImportListMovie> .CreateListOfSize(5)
                           .Build().ToList();

            _existingMovies = Builder <Movie> .CreateListOfSize(3)
                              .TheFirst(1)
                              .With(s => s.TmdbId = 6)
                              .With(s => s.ImdbId = "6")
                              .TheNext(1)
                              .With(s => s.TmdbId = 7)
                              .With(s => s.ImdbId = "7")
                              .TheNext(1)
                              .With(s => s.TmdbId = 8)
                              .With(s => s.ImdbId = "8")
                              .Build().ToList();

            _list2Movies = Builder <ImportListMovie> .CreateListOfSize(3)
                           .TheFirst(1)
                           .With(s => s.TmdbId = 6)
                           .With(s => s.ImdbId = "6")
                           .TheNext(1)
                           .With(s => s.TmdbId = 7)
                           .With(s => s.ImdbId = "7")
                           .TheNext(1)
                           .With(s => s.TmdbId = 8)
                           .With(s => s.ImdbId = "8")
                           .Build().ToList();

            _importListFetch = new ImportListFetchResult
            {
                Movies     = _list1Movies,
                AnyFailure = false
            };

            _commandAll = new ImportListSyncCommand
            {
            };

            _commandSingle = new ImportListSyncCommand
            {
                DefinitionId = 1
            };

            Mocker.GetMock <IImportListFactory>()
            .Setup(v => v.Enabled())
            .Returns(_importLists);

            Mocker.GetMock <IImportExclusionsService>()
            .Setup(v => v.GetAllExclusions())
            .Returns(new List <ImportExclusion>());

            Mocker.GetMock <IMovieService>()
            .Setup(v => v.MovieExists(It.IsAny <Movie>()))
            .Returns(false);

            Mocker.GetMock <IMovieService>()
            .Setup(v => v.AllMovieTmdbIds())
            .Returns(new List <int>());

            Mocker.GetMock <IFetchAndParseImportList>()
            .Setup(v => v.Fetch())
            .Returns(_importListFetch);
        }
        private Mock <IImportList> CreateListResult(int id, bool enabled, bool enabledAuto, ImportListFetchResult fetchResult)
        {
            var importListDefinition = new ImportListDefinition {
                Id = id, EnableAuto = enabledAuto
            };

            var mockImportList = new Mock <IImportList>();

            mockImportList.SetupGet(s => s.Definition).Returns(importListDefinition);
            mockImportList.SetupGet(s => s.Enabled).Returns(enabled);
            mockImportList.SetupGet(s => s.EnableAuto).Returns(enabledAuto);
            mockImportList.Setup(s => s.Fetch()).Returns(fetchResult);

            _importLists.Add(mockImportList.Object);

            return(mockImportList);
        }
 private void GivenList(int id, bool enabled, bool enabledAuto, ImportListFetchResult fetchResult)
 {
     CreateListResult(id, enabled, enabledAuto, fetchResult);
 }