Ejemplo n.º 1
0
        public async Task TakeNewShouldGetTwo()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new ApplicationDbContext(options.Options);

            var repository = new EfRepository <Game>(context);
            var service    = new GamesService(repository);
            var models     = new List <SuggestionToGameViewModel>
            {
                new SuggestionToGameViewModel()
                {
                    Title       = "test",
                    Description = "test",
                    ImageUrl    = "test",
                },
                new SuggestionToGameViewModel()
                {
                    Title       = "test1",
                    Description = "test",
                    ImageUrl    = "test",
                },
            };

            foreach (var model in models)
            {
                await service.AddAsync(model);
            }

            var actual = await service.TakeNewAsync <NewGamesViewModel>();

            Assert.Equal(2, actual.Count());
        }
Ejemplo n.º 2
0
        public async Task DoesGameExistShouldReturnFalse()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new ApplicationDbContext(options.Options);

            var repository = new EfRepository <Game>(context);
            var service    = new GamesService(repository);
            var model      = new SuggestionToGameViewModel()
            {
                Title       = "test",
                Description = "test",
                ImageUrl    = "test",
            };

            await service.AddAsync(model);

            var actual = await service.DoesGameExist("hahahaaa");

            Assert.False(actual);
        }
Ejemplo n.º 3
0
        public async Task AddOnGameShouldAdd()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new ApplicationDbContext(options.Options);

            var repository = new EfRepository <Game>(context);
            var service    = new GamesService(repository);
            var model      = new SuggestionToGameViewModel()
            {
                Title       = "test",
                Description = "test",
                ImageUrl    = "test",
            };

            await service.AddAsync(model);

            var actual = await service.GetAll <GamesDropDownViewModel>();

            Assert.Single(actual);
        }