Exemplo n.º 1
0
        public async Task EditMovieShouldThrowIfIdIsNotFound()
        {
            var repository = new EfDeletableEntityRepository <Movie>(new ApplicationDbContext(this.options.Options));
            var service    = new MoviesService(repository);

            var diffMovie = new AddMovieInputModel
            {
                Id              = 5,
                Name            = "Taxi 2",
                Year            = 2000,
                Actors          = "Samy Naceri, Frédéric Diefenthal, Marion Cotillard",
                AgeRestriction  = 0,
                Description     = "funny",
                Director        = "Gérard Pirès",
                Duration        = 86,
                Rating          = 7.5,
                Price           = 8,
                Genre           = "Action, Comedy, Crime",
                TrailerUrl      = "url",
                TrailerVideoUrl = "url",
            };

            await service.AddAsync(this.movie);

            Assert.Throws <ArgumentNullException>(() => service.EditAsync(diffMovie).GetAwaiter().GetResult());
        }
Exemplo n.º 2
0
        public async Task EditMovieShouldWorkCorrectly()
        {
            var repository = new EfDeletableEntityRepository <Movie>(new ApplicationDbContext(this.options.Options));
            var service    = new MoviesService(repository);

            var diffMovie = new AddMovieInputModel
            {
                Id              = 1,
                Name            = "Taxi 2",
                Year            = 2000,
                Actors          = "Samy Naceri, Frédéric Diefenthal, Marion Cotillard",
                AgeRestriction  = 0,
                Description     = "funny",
                Director        = "Gérard Pirès",
                Duration        = 86,
                Rating          = 7.5,
                Price           = 8,
                Genre           = "Action, Comedy, Crime",
                TrailerUrl      = "url",
                TrailerVideoUrl = "url",
            };

            await service.AddAsync(this.movie);

            await service.EditAsync(diffMovie);

            Assert.Equal("Taxi 2", repository.All().FirstOrDefault().Name);
            Assert.Equal(2000, repository.All().FirstOrDefault().Year);
            Assert.Equal(7.5, repository.All().FirstOrDefault().Rating);
        }