예제 #1
0
        public void GetAllReturnsGenreModels()
        {
            var genres        = new List <Genre>();
            var mockGenreRepo = new Mock <IGenresRepository>();

            mockGenreRepo.Setup(x => x.All()).Returns(genres.AsQueryable());
            genres.Add(new Genre()
            {
                Id   = "test",
                Name = "123"
            });
            genres.Add(new Genre()
            {
                Id   = "123",
                Name = "test"
            });

            var service = new GenresService(mockGenreRepo.Object);

            var result      = service.AllGenres();
            var secondGenre = result.ToArray()[1];

            Assert.Equal(2, result.Count());
            Assert.Equal("test", result.First().Id);
            Assert.Equal("123", result.First().Name);
            Assert.Equal("123", secondGenre.Id);
            Assert.Equal("test", secondGenre.Name);
        }