Ejemplo n.º 1
0
        public async Task TwoVotesOnPostFromOneUserShouldCountOnce()
        {
            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.VoteOnPostAsync("1", "1", true);

            await service.VoteOnPostAsync("1", "1", true);

            var actual = await service.GetVotesOnPostAsync("1");

            Assert.Equal(1, actual);
        }