public void GetPollsParticipantsShouldReturnAllParticipantsFromPoll() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Tests").Options; var dbContext = new ApplicationDbContext(options); var service = new PollsService(dbContext); dbContext.Polls.Add(new Poll()); var user = new LessplasticUser { UserName = "******" }; var secondUser = new LessplasticUser { UserName = "******" }; dbContext.Users.Add(user); dbContext.Users.Add(secondUser); dbContext.SaveChanges(); var poll = dbContext.Polls.First(); service.AddParticipant(poll, "test"); service.AddParticipant(poll, "test2"); var participants = service.GetPollsParticipants(poll.Id); Assert.Equal(2, participants.Length); }
public void AddParticipantShouldAddParticipantToPoll() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Tests").Options; var dbContext = new ApplicationDbContext(options); var service = new PollsService(dbContext); dbContext.Polls.Add(new Poll()); var user = new LessplasticUser { UserName = "******" }; dbContext.Users.Add(user); dbContext.SaveChanges(); var poll = dbContext.Polls.First(); service.AddParticipant(poll, "test"); Assert.Equal(1, dbContext.PollsUsers.Count()); }