Ejemplo n.º 1
0
        public async Task SecondVoteOnSuggestionGameFromOneUserShouldNotCount()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context                  = new ApplicationDbContext(options.Options);
            var postRepository           = new EfRepository <VoteOnPost>(context);
            var guideRepository          = new EfRepository <VoteOnGuide>(context);
            var suggestionGameRepository = new EfRepository <VoteOnSuggestionGame>(context);
            var service                  = new VotesService(postRepository, guideRepository, suggestionGameRepository);

            await service.VoteOnSuggestionGameAsync(1, "1");

            var actual = await service.VoteOnSuggestionGameAsync(1, "1");

            var expected = "You have already voted for this game!";

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 2
0
        public async Task VoteOnSuggestionGameAdd()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context                  = new ApplicationDbContext(options.Options);
            var postRepository           = new EfRepository <VoteOnPost>(context);
            var guideRepository          = new EfRepository <VoteOnGuide>(context);
            var suggestionGameRepository = new EfRepository <VoteOnSuggestionGame>(context);
            var service                  = new VotesService(postRepository, guideRepository, suggestionGameRepository);

            await service.VoteOnSuggestionGameAsync(1, "1");

            var actual   = suggestionGameRepository.All().Count();
            var expected = 1;

            Assert.Equal(expected, actual);
        }