public void NewFilm_InsertOrUpdate_FilmAdded() { var film = new FilmDetailModel() { Id = Guid.Empty, OriginalName = "A", Genre = GenreEnum.Action, CzechName = "B", TitleFotoUrl = "titlefoto.png", Description = "A film!", Country = "Murica", Reviews = new List <ReviewListModel>(), Actors = new List <ActedInFilmDetailModel>(), Directors = new List <DirectedFilmDetailModel>() }; using var dbxAssert = _dbContextFactory.CreateDbContext(); film = _filmRepositorySUT.InsertOrUpdate(film); var filmFromDb = dbxAssert.Films.Single(i => i.Id == film.Id); var film2 = FilmMapper.MapToDetailModel(filmFromDb); Assert.Equal(film, film2, FilmDetailModel.FilmDetailModelComparer); Assert.Equal(film.Reviews, film2.Reviews, ReviewListModel.ReviewListModelComparer); Assert.Equal(film.Actors, film2.Actors, ActedInFilmDetailModel.ActedInFilmDetailModelComparer); Assert.Equal(film.Directors, film2.Directors, DirectedFilmDetailModel.DirectedFilmDetailModelComparer); }
public void GetById_SeedFilm() { var film2 = _filmRepositorySUT.GetById(Seed.GreaseFilm.Id); var film = FilmMapper.MapToDetailModel(Seed.GreaseFilm); Assert.Equal(film, film2, FilmDetailModel.FilmDetailModelComparer); Assert.Equal(film.Reviews, film2.Reviews, ReviewListModel.ReviewListModelComparer); Assert.Equal(film.Actors, film2.Actors, ActedInFilmDetailModel.ActedInFilmDetailModelComparer); Assert.Equal(film.Directors, film2.Directors, DirectedFilmDetailModel.DirectedFilmDetailModelComparer); }
public FilmFacadeTests() { var dbContextFactory = new DbContextInMemoryFactory(nameof(ActorFacadeTest)); var unitOfWork = new UnitOfWork(dbContextFactory); repository = new Repository <FilmEntity>(unitOfWork); mapper = new FilmMapper(); facadeTestUnit = new FilmFacade(unitOfWork, repository, mapper); }
public void GetAll_Single_SeedFilm() { var film = _filmRepositorySUT.GetAll().Single(i => i.Id == Seed.GreaseFilm.Id); Assert.Equal(FilmMapper.MapToListModel(Seed.GreaseFilm), film, FilmListModel.IdOriginalNameComparer); }