Example #1
0
        public void GetVoteShouldReturnTheCorrectVote()
        {
            var list           = new List <Vote>();
            var mockRepository = new Mock <IDeletableEntityRepository <Vote> >();

            mockRepository
            .Setup(x => x.AllAsNoTracking())
            .Returns(list.AsQueryable());

            mockRepository
            .Setup(x => x.AddAsync(It.IsAny <Vote>()))
            .Callback((Vote vote) => list.Add(vote));

            var service = new VotesService(mockRepository.Object);

            service.CreateAsync(new CreateVoteDTO
            {
                ForUserId = "a",
                VoteValue = true,
                VoterId   = "c",
            }).GetAwaiter();

            var vote = service.GetVote <VotesViewModel>("a", "c");

            Assert.True(vote.VoteValue);
        }