示例#1
0
        public void SearchWithNoResultsTest()
        {
            // Arrange:
            var mediaList = PopulateMedia();

            var mockRepo = new MockSubtitleRepository(mediaList);
            var controller = new BrowseController(mockRepo);

            // Act:
            var result = controller.Search("Hobbit");

            // Assert:
            var viewResult = (ViewResult)result;
            Assert.AreEqual("Error", viewResult.ViewName);
        }
示例#2
0
        public void MoviesByGenreTest()
        {
            // Arrange:
            var mediaList = PopulateMedia();
            var mockRepo = new MockSubtitleRepository(mediaList);
            var controller = new BrowseController(mockRepo);

            // Act:
            var result = controller.MoviesByGenre("Sci-Fi");

            // Assert:
            var viewResult = (ViewResult)result;

            List<Media> media = (viewResult.Model as IEnumerable<Media>).ToList();
            Assert.IsTrue(media.Count() == 1);
            Assert.IsTrue(media[0].Name == "The Matrix");
        }
示例#3
0
        public void SearchWithResultTest()
        {
            // Arrange:
            var mediaList = PopulateMedia();

            var mockRepo = new MockSubtitleRepository(mediaList);
            var controller = new BrowseController(mockRepo);

            // Act:
            var result = controller.Search("Catch");

            // Assert:
            var viewResult = (ViewResult)result;

            List<Media> media = (viewResult.Model as IEnumerable<Media>).ToList();
            Assert.IsTrue(media.Count() == 1);
            Assert.IsTrue(media[0].Name == "Catch me if you can");
        }
示例#4
0
        public void SearchWithTwoResults()
        {
            // Arrange:
            var mediaList = PopulateMedia();

            var mockRepo = new MockSubtitleRepository(mediaList);
            var controller = new BrowseController(mockRepo);

            // Act:
            var result = controller.Search("The"); // virkar ekki, þótt þetta virki á síðunni sjálfri :/
            // var result = controller.Search("Catch me if you can"); // Þetta virkar hinsvegar

            // Assert:
            var viewResult = (ViewResult)result;

            List<Media> media = (viewResult.Model as IEnumerable<Media>).ToList();
            media.Sort((x, y) => string.Compare(x.Name, y.Name));
            Assert.IsTrue(media.Count() == 2);
            Assert.IsTrue(media[0].Name == "The Matrix");
            Assert.IsTrue(media[1].Name == "The Notebook");
        }