Example #1
0
        public void Local_search_searches_track_album_and_artist_names()
        {
            // Arrange
            HomeController controller = new HomeController();
            var repo = new TestDB();
            var a1 = new Album { Id = 1, Artist = "Metallica", Name = "xpto", Year = 1986 };
            var a2 = new Album { Id = 2, Artist = "V/A", Name = "..And Justice for All", Year = 1988 };
            var a3 = new Album { Id = 3, Artist = "xpto", Name = "Master Of Puppets", Year = 1985 };
            repo.Tracks.Add(new Track { Id = 1, Artist = "Metallica", Name = "Battery", Duration = 5.12, Album = a3 });
            repo.Tracks.Add(new Track { Id = 2, Artist = "xpto", Name = "Polly", Duration = 12.3, Album = a2 });
            repo.Tracks.Add(new Track { Id = 3, Artist = "Nirvana", Name = "xpto", Duration = 12.3, Album = a1 });
            repo.Albums.Add(a1);
            repo.Albums.Add(a2);
            repo.Albums.Add(a3);
            string query = "xpto";

            controller._repo = repo;
            // TODO: Mock data mappers
            controller.a2mMapper = new SpotiChelas.DataMappers.AlbumToAlbumModelMapper();
            controller._t2mMapper = new SpotiChelas.DataMappers.TrackToTrackModelMapper();

            // Act
            ViewResult result = controller.Search(query) as ViewResult;
            var model = result.Model as SearchResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(model, typeof(SearchResult));
            Assert.AreEqual(1, model.Albums.Count());
            Assert.AreEqual(query, model.Albums.First().Name);
            Assert.AreEqual(1, model.Tracks.Count());
            Assert.AreEqual(query, model.Tracks.First().Name);
            Assert.AreEqual(1, model.Artists.Count());
            Assert.AreEqual(query, model.Artists.First());
        }
Example #2
0
        public void Index()
        {
            // Arrange
            HomeController controller = new HomeController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.AreEqual("Welcome to ASP.NET MVC!", result.ViewBag.Message);
        }
Example #3
0
        public void About()
        {
            // Arrange
            HomeController controller = new HomeController();

            // Act
            ViewResult result = controller.About() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Example #4
0
        public void Local_Search_Model_is_always_of_type_SearchResult()
        {
            // Arrange
            HomeController controller = new HomeController();
            controller._repo = new TestDB();

            // Act
            var result = controller.Search("") as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Model);
            Assert.AreEqual(typeof(SearchResult), result.Model.GetType());
        }