public async void CanGetParticipants() { DbContextOptions <ClientSideDanceFellowsDbContext> options = new DbContextOptionsBuilder <ClientSideDanceFellowsDbContext>().UseInMemoryDatabase("GetParticipants").Options; using (ClientSideDanceFellowsDbContext context = new ClientSideDanceFellowsDbContext(options)) { Participant testParticipant = CreateParticipant(); RegisteredCompetitor testRegisteredCompetitor = new RegisteredCompetitor { CompetitionID = 1, ParticipantID = 2 }; List <RegisteredCompetitor> listRC = new List <RegisteredCompetitor>(); listRC.Add(testRegisteredCompetitor); Participant testParticipant1 = new Participant() { ID = 2, WSC_ID = 2, FirstName = "Ricky", LastName = "Bobby", MinLevel = Level.Novice, MaxLevel = Level.Advanced, EligibleCompetitor = true, RegisteredCompetitors = listRC }; ParticipantManagementService participantService = new ParticipantManagementService(context); await participantService.CreateParticipant(testParticipant); await participantService.CreateParticipant(testParticipant1); IEnumerable <Participant> expected = new List <Participant> { testParticipant, testParticipant1 }; IEnumerable <Participant> actual = await participantService.GetParticipants(); Assert.Equal(expected, actual); } }
public async void CanCreateParticipant() { DbContextOptions <ClientSideDanceFellowsDbContext> options = new DbContextOptionsBuilder <ClientSideDanceFellowsDbContext>().UseInMemoryDatabase("CreateParticipant").Options; using (ClientSideDanceFellowsDbContext context = new ClientSideDanceFellowsDbContext(options)) { Participant testParticipant = CreateParticipant(); ParticipantManagementService participantService = new ParticipantManagementService(context); await participantService.CreateParticipant(testParticipant); var result = context.Participants.FirstOrDefault(a => a.ID == testParticipant.ID); Assert.Equal(testParticipant, result); } }
public async void CanGetRegisteredCompetitors() { DbContextOptions <ClientSideDanceFellowsDbContext> options = new DbContextOptionsBuilder <ClientSideDanceFellowsDbContext>().UseInMemoryDatabase("GetRegisteredCompetitors").Options; using (ClientSideDanceFellowsDbContext context = new ClientSideDanceFellowsDbContext(options)) { Participant testParticipant = CreateParticipant(); ParticipantManagementService participantService = new ParticipantManagementService(context); await participantService.CreateParticipant(testParticipant); IEnumerable <RegisteredCompetitor> expected = testParticipant.RegisteredCompetitors; IEnumerable <RegisteredCompetitor> actual = await participantService.GetRegisteredCompetitors(testParticipant.ID); Assert.Equal(expected, actual); } }
public async void CanListValidCompetitors() { DbContextOptions <ClientSideDanceFellowsDbContext> options = new DbContextOptionsBuilder <ClientSideDanceFellowsDbContext>().UseInMemoryDatabase("ListValidCompetitors").Options; using (ClientSideDanceFellowsDbContext context = new ClientSideDanceFellowsDbContext(options)) { RegisteredCompetitorManagementService registeredCompetitorService = new RegisteredCompetitorManagementService(context); ParticipantManagementService participantManagementService = new ParticipantManagementService(context); Participant testParticipant = new Participant() { ID = 1, WSC_ID = 1, FirstName = "JimBob", LastName = "Franklin", MinLevel = Level.Novice, MaxLevel = Level.Advanced, EligibleCompetitor = true, }; Participant testParticipant1 = new Participant() { ID = 2, WSC_ID = 0, FirstName = "Ricky", LastName = "Bobby", MinLevel = Level.Novice, MaxLevel = Level.Advanced, EligibleCompetitor = false, }; await participantManagementService.CreateParticipant(testParticipant); await participantManagementService.CreateParticipant(testParticipant1); IEnumerable <Participant> expected = new List <Participant> { testParticipant }; IEnumerable <Participant> actual = await registeredCompetitorService.ListValidCompetitors(); Assert.Equal(expected, actual); } }
public async void CanShowParticipant() { DbContextOptions <ClientSideDanceFellowsDbContext> options = new DbContextOptionsBuilder <ClientSideDanceFellowsDbContext>().UseInMemoryDatabase("ShowParticipant").Options; using (ClientSideDanceFellowsDbContext context = new ClientSideDanceFellowsDbContext(options)) { RegisteredCompetitor testRegisteredCompetitor = CreateRegisteredCompetitor(); RegisteredCompetitorManagementService registeredCompetitorService = new RegisteredCompetitorManagementService(context); ParticipantManagementService participantManagementService = new ParticipantManagementService(context); await participantManagementService.CreateParticipant(testRegisteredCompetitor.Participant); Participant expected = testRegisteredCompetitor.Participant; Participant actual = await registeredCompetitorService.ShowParticipant(testRegisteredCompetitor.Participant.ID); Assert.Equal(expected, actual); } }