public async Task Create_WithInvalidInput_ShouldThrowException() { var dbContext = ApplicationDbContextCreatorInMemory.InitializeContext(); await this.SeedData(dbContext); var tvshowRepository = new EfDeletableEntityRepository <TVShow>(dbContext); var genresRepository = new EfDeletableEntityRepository <Genre>(dbContext); var service = new TVShowsService(tvshowRepository, genresRepository); var input = new TVShowsCreateModel() { }; await Assert.ThrowsAsync <ArgumentNullException>(() => service.Create(input)); }
public async Task Create_WithValidInput_ShouldReturnValidResult() { var dbContext = ApplicationDbContextCreatorInMemory.InitializeContext(); await this.SeedData(dbContext); var tvshowRepository = new EfDeletableEntityRepository <TVShow>(dbContext); var genresRepository = new EfDeletableEntityRepository <Genre>(dbContext); var service = new TVShowsService(tvshowRepository, genresRepository); var input = new TVShowsCreateModel() { Title = "Titanic", Country = "USA", GenreId = 1, }; var movie = service.Create(input); var result = service.GetByTitle <TVShowViewModel>("Titanic"); Assert.Equal("USA", result.Country); }