Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }