Ejemplo n.º 1
0
        public void TestCreateAsync()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var repository         = new EfDeletableEntityRepository <Game>(new ApplicationDbContext(options.Options));
            var commentsRepository = new EfDeletableEntityRepository <Comment>(new ApplicationDbContext(options.Options));

            var service = new GamesService(repository, commentsRepository);

            var game = new Game
            {
                Title       = "test",
                CategoryId  = 1,
                Description = "sds",
                ReleaseDate = DateTime.UtcNow,
                CompanyName = "tests",
                PictureUrl  = "est",
            };

            service.CreateAsync(game.Title, game.PictureUrl, game.ReleaseDate, game.CompanyName, game.Description, game.CategoryId).GetAwaiter().GetResult();

            var counter = repository.All().CountAsync().GetAwaiter().GetResult();

            Assert.Equal(1, counter);
        }