Example #1
0
        public void CorrectSortMovieByAToZSortsMoviesAlphabeticallyAndReturnsTheirIdsAndWrapperAsADictionary()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService        _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);
            Dictionary <int, byte[]> expected           = new Dictionary <int, byte[]>();

            expected.Add(3, new byte[80]);
            expected.Add(2, new byte[120]);
            expected.Add(1, new byte[100]);

            try
            {
                Assert.AreNotEqual(_iallMoviesService.SortMoviesByTitle(), null);
                Assert.AreEqual(_iallMoviesService.SortMoviesByTitle(), expected);
            }
            catch (NoDataBaseTableRecordsException ex)
            {
                Logger.WriteToLogFile(ex.ToString());
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
Example #2
0
        public void CorrectGetMovieReturnsTheMovieAsATupleFromItsIdAndGenre()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService     _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);
            Tuple <Movie, string> expectedMovie      = new Tuple <Movie, string>(new Movie {
                id = 1, title = "Titanic", genre = 1, pg = 0, duration = 210, summary = "This is the description of the Titanic movie.", year = new DateTime(1997, 11, 1), picture = new byte[100]
            }, "Drama");
            Tuple <Movie, string> movie = _iallMoviesService.GetMovie(1);

            Assert.AreNotEqual(_iallMoviesService.GetMovie(1), null);
            Assert.AreEqual(expectedMovie.Item1.id, movie.Item1.id);
            Assert.AreEqual(expectedMovie.Item1.AVGRating, movie.Item1.AVGRating);
            Assert.AreEqual(expectedMovie.Item1.comments, movie.Item1.comments);
            Assert.AreEqual(expectedMovie.Item1.duration, movie.Item1.duration);
            Assert.AreEqual(expectedMovie.Item1.genre, movie.Item1.genre);
            Assert.AreEqual(expectedMovie.Item1.genre1, movie.Item1.genre1);
            Assert.AreEqual(expectedMovie.Item1.pg, movie.Item1.pg);
            Assert.AreEqual(expectedMovie.Item1.picture, movie.Item1.picture);
            Assert.AreEqual(expectedMovie.Item1.ratings, movie.Item1.ratings);
            Assert.AreEqual(expectedMovie.Item1.summary, movie.Item1.summary);
            Assert.AreEqual(expectedMovie.Item1.title, movie.Item1.title);
            Assert.AreEqual(expectedMovie.Item1.users, movie.Item1.users);
            Assert.AreEqual(expectedMovie.Item1.year, movie.Item1.year);
            Assert.AreEqual(expectedMovie.Item2, movie.Item2);
        }
Example #3
0
        public void CorrectGetMovieGenreReturnsTheMovieGenreAsIntNumber()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);

            Assert.AreNotEqual(_iallMoviesService.GetMovieGenre("Drama"), null);
            Assert.AreEqual(_iallMoviesService.GetMovieGenre("Drama"), 1);
        }
Example #4
0
        public void CorrectGetUserInfoReturnsATupleFromUsersIdAndPosition()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);

            Assert.AreNotEqual(_iallMoviesService.GetUserInfo("petya", "myPass"), null);
            Assert.AreEqual(_iallMoviesService.GetUserInfo("petya", "myPass"), new Tuple <int, string>(1, "admin"));
        }
Example #5
0
        public void CorrectGetMoviesTitleReturnsTheTitleOfTheMovieByItsId()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);
            Movie             expectedMovie      = new Movie {
                id = 1, title = "Titanic", genre = 1, pg = 0, duration = 210, summary = "This is the description of the Titanic movie.", year = new DateTime(1997, 11, 1), picture = new byte[100]
            };

            Assert.AreNotEqual(_iallMoviesService.SetMovieTitle(1), null);
            Assert.AreEqual(_iallMoviesService.SetMovieTitle(1), expectedMovie.title);
        }
Example #6
0
        public void CorrectSortMoviesByOldestMoviesSortsTheMoviesAndReturnsThemAsADictionary()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService        _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);
            Dictionary <int, byte[]> expected           = new Dictionary <int, byte[]>();

            expected.Add(3, new byte[80]);
            expected.Add(2, new byte[120]);
            expected.Add(1, new byte[100]);

            Assert.AreNotEqual(_iallMoviesService.SortByDate(), null);
            Assert.AreEqual(expected.Count, _iallMoviesService.SortByDate().Count);
            Assert.AreEqual(_iallMoviesService.SortByDate(), expected);
        }
Example #7
0
        public void CorrectGetMoviesTitlesReturnsAListOfMoviesTitlesFromDB()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);
            List <string>     expected           = new List <string> {
                "Titanic", "Terminator", "Star Wars 5"
            };

            Assert.AreNotEqual(_iallMoviesService.GetMovieTitles(), null);
            Assert.AreEqual(_iallMoviesService.GetMovieTitles().Count, expected.Count);
            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual(_iallMoviesService.GetMovieTitles()[i], expected[i]);
            }
        }
Example #8
0
        public void CorrectDeleteMovieDeletesAMovieFromDB()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);

            try
            {
                _iallMoviesService.DeleteMovie(3);
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
Example #9
0
        public void CorrectFilterMoviesByPGReturnsFilteredMoviesAsADictionaryOfItsIdsAndItsWrappers()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);
            Movie             expectedMovie      = new Movie {
                id = 2, title = "Terminator", genre = 6, pg = 12, duration = 120, summary = "This is the description of the Terminator movie.", year = new DateTime(1984, 10, 26), picture = new byte[120]
            };
            Dictionary <int, byte[]> expected = new Dictionary <int, byte[]>();

            expected.Add(expectedMovie.id, expectedMovie.picture);
            Dictionary <int, byte[]> actual = _iallMoviesService.FilterMoviesByPG(12);

            Assert.AreNotEqual(_iallMoviesService.FilterMoviesByPG(12), null);
            foreach (var item in actual)
            {
                Assert.AreEqual(item.Key, expectedMovie.id);
                Assert.AreEqual(item.Value, expectedMovie.picture);
            }
        }
Example #10
0
        public void CorrectEditMovieEditsACertainMovieInTheDB()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);

            try
            {
                _iallMoviesService.EditMovie(2, "The Hunger Games: Catching Fire", 7, 14, new DateTime(2013, 11, 22), "This is the description of The Hunger Games: Catching Fire movie.", new byte[110], 180);
                _iallMoviesService.EditMovie(-2, "The Hunger Games: Catching Fire", 7, 14, new DateTime(2013, 11, 22), "This is the description of The Hunger Games: Catching Fire movie.", new byte[110], 180);
                _iallMoviesService.EditMovie(2, "The Hunger Games: Catching Fire", 7, 14, new DateTime(2013, 11, 22), "This is the description of The Hunger Games: Catching Fire movie.", null, 180);
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
Example #11
0
        public void CorrectGetMoviesReturnsADictionaryOfItsIdsAndWrappers()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);
            Movie             expectedMovie1     = new Movie {
                id = 1, title = "Titanic", genre = 1, pg = 0, duration = 210, summary = "This is the description of the Titanic movie.", year = new DateTime(1997, 11, 1), picture = new byte[100]
            };
            Movie expectedMovie2 = new Movie {
                id = 2, title = "Terminator", genre = 6, pg = 12, duration = 120, summary = "This is the description of the Terminator movie.", year = new DateTime(1984, 10, 26), picture = new byte[120]
            };
            Movie expectedMovie3 = new Movie {
                id = 3, title = "Star Wars 5", genre = 7, pg = 0, duration = 150, summary = "This is the description of the Star Wars 5 movie.", year = new DateTime(1984, 4, 23), picture = new byte[80]
            };
            Dictionary <int, byte[]> dict = new Dictionary <int, byte[]>();

            dict.Add(expectedMovie1.id, expectedMovie1.picture);
            dict.Add(expectedMovie2.id, expectedMovie2.picture);
            dict.Add(expectedMovie3.id, expectedMovie3.picture);

            Assert.AreNotEqual(_iallMoviesService.SetMoviesList(), null);
            Assert.AreEqual(_iallMoviesService.SetMoviesList(), dict);
            Assert.AreEqual(dict.Count, _iallMoviesService.SetMoviesList().Count);
        }
Example #12
0
        public void CorrectGetMoviesByTitlesReturnsADictionaryOfMoviesIdsAndWrappers()
        {
            DummyMockedAllMoviesRepository _dummyMockedAllMoviesRepo = new DummyMockedAllMoviesRepository();
            IAllMoviesService _iallMoviesService = new AllMoviesService(_dummyMockedAllMoviesRepo._allMoviesRepo);
            Movie             expectedMovie      = new Movie {
                id = 1, title = "Titanic", genre = 1, pg = 0, duration = 210, summary = "This is the description of the Titanic movie.", year = new DateTime(1997, 11, 1), picture = new byte[100]
            };
            Dictionary <int, byte[]> expected = new Dictionary <int, byte[]>();

            expected.Add(expectedMovie.id, expectedMovie.picture);
            Dictionary <int, byte[]> actual = _iallMoviesService.GetMoviesByTitles(new List <string> {
                expectedMovie.title
            });

            Assert.AreNotEqual(_iallMoviesService.GetMoviesByTitles(new List <string> {
                expectedMovie.title
            }), null);
            Assert.AreEqual(expected.Count, actual.Count);
            foreach (var item in expected)
            {
                Assert.AreEqual(item.Key, 1);
                Assert.AreEqual(item.Value, new byte[100]);
            }
        }