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

            mockGenreRepo.Setup(x => x.All()).Returns(genres.AsQueryable());

            var service = new GenresService(mockGenreRepo.Object);

            Assert.ThrowsAsync <ArgumentException>(() => service.EditGenre(new Web.ViewModels.Genres.EditGenreInputModel()
            {
                Id = "Ivan"
            }));
        }
예제 #2
0
        public async Task EditGenreAsyncChangesNameCorrectly()
        {
            var genres        = new List <Genre>();
            var mockGenreRepo = new Mock <IGenresRepository>();

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

            var service = new GenresService(mockGenreRepo.Object);

            await service.EditGenre(new Web.ViewModels.Genres.EditGenreInputModel()
            {
                Id = "test123", Name = "gosho"
            });

            Assert.Single(genres);
            Assert.Equal("gosho", genres.First().Name);
            Assert.Equal("test123", genres.First().Id);
        }