public void ParticipantIDSet() { RegisteredCompetitor testRegComp = new RegisteredCompetitor(); testRegComp.ParticipantID = 1; Assert.Equal(1, testRegComp.ParticipantID); }
public async void CanGetCompetitions() { DbContextOptions <ClientSideDanceFellowsDbContext> options = new DbContextOptionsBuilder <ClientSideDanceFellowsDbContext>().UseInMemoryDatabase("GetCompetitions").Options; using (ClientSideDanceFellowsDbContext context = new ClientSideDanceFellowsDbContext(options)) { Competition testCompetition = CreateCompetition(); RegisteredCompetitor testRegisteredCompetitor = new RegisteredCompetitor { CompetitionID = 2, ParticipantID = 2 }; List <RegisteredCompetitor> listRC = new List <RegisteredCompetitor>(); listRC.Add(testRegisteredCompetitor); Competition testCompetition2 = new Competition() { ID = 2, CompType = CompType.Classic, Level = Level.Novice, RegisteredCompetitors = listRC }; CompetitionManagementService competitionService = new CompetitionManagementService(context); await competitionService.CreateCompetition(testCompetition); await competitionService.CreateCompetition(testCompetition2); IEnumerable <Competition> expected = new List <Competition> { testCompetition, testCompetition2 }; IEnumerable <Competition> actual = await competitionService.GetCompetitions(); Assert.Equal(expected, actual); } }
public async void GetRegisteredCompetitors() { DbContextOptions <ClientSideDanceFellowsDbContext> options = new DbContextOptionsBuilder <ClientSideDanceFellowsDbContext>().UseInMemoryDatabase("GetRegisteredCompetitorsTwo").Options; using (ClientSideDanceFellowsDbContext context = new ClientSideDanceFellowsDbContext(options)) { RegisteredCompetitor testRegisteredCompetitor = CreateRegisteredCompetitor(); RegisteredCompetitor testRegisteredCompetitor1 = new RegisteredCompetitor { ParticipantID = 2, CompetitionID = 1, Role = Role.Lead, Placement = Placement.Position2, BibNumber = 101, ChiefJudgeScore = 8, JudgeOneScore = 8, JudgeTwoScore = 8, JudgeThreeScore = 8, JudgeFourScore = 8, JudgeFiveScore = 8, JudgeSixScore = 8, Participant = CreateParticipant1(), Competition = CreateCompetition1(), EventID = 1 }; RegisteredCompetitorManagementService registeredCompetitorService = new RegisteredCompetitorManagementService(context); await registeredCompetitorService.CreateRegisteredCompetitor(testRegisteredCompetitor); await registeredCompetitorService.CreateRegisteredCompetitor(testRegisteredCompetitor1); IEnumerable <RegisteredCompetitor> expected = new List <RegisteredCompetitor> { testRegisteredCompetitor, testRegisteredCompetitor1 }; IEnumerable <RegisteredCompetitor> actual = await registeredCompetitorService.GetRegisteredCompetitors(); Assert.Equal(expected, actual); } }
public void JudgeSixScoreSet() { RegisteredCompetitor testRegComp = new RegisteredCompetitor(); testRegComp.JudgeSixScore = 8; Assert.Equal(8, testRegComp.JudgeSixScore); }
public void BibNumberSet() { RegisteredCompetitor testRegComp = new RegisteredCompetitor(); testRegComp.BibNumber = 1234; Assert.Equal(1234, testRegComp.BibNumber); }
/// <summary> /// Serialized RegisteredCompetitor into JSON object. /// </summary> /// <param name="reg"></param> /// <returns>JSON Object</returns> private async Task <List <object> > BuildRegistrationObject(RegisteredCompetitor reg) { if (reg == null) { return(null); } List <object> data = new List <object>(); Competition competition = await _context.ShowCompetition(reg.CompetitionID); reg.Competition = competition; Participant participant = await _context.ShowParticipant(reg.ParticipantID); reg.Participant = participant; competition.RegisteredCompetitors = null; reg.Competition = null; reg.Participant = null; participant.RegisteredCompetitors = null; string package = JsonConvert.SerializeObject(competition) + " | " + JsonConvert.SerializeObject(reg) + " | " + JsonConvert.SerializeObject(participant); data.Add(competition); data.Add(participant); data.Add(reg); return(data); }
public void PlacementSet() { RegisteredCompetitor testRegComp = new RegisteredCompetitor(); testRegComp.Placement = Placement.Finalled; Assert.Equal(Placement.Finalled, testRegComp.Placement); }
public void RoleSet() { RegisteredCompetitor testRegComp = new RegisteredCompetitor(); testRegComp.Role = Role.Follow; Assert.Equal(Role.Follow, testRegComp.Role); }
public void CompetitionIDSet() { RegisteredCompetitor testRegComp = new RegisteredCompetitor(); testRegComp.CompetitionID = 1; Assert.Equal(1, testRegComp.CompetitionID); }
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 Task <IActionResult> Delete(RegisteredCompetitor registeredCompetitor) { await _context.DeleteRegisteredCompetitor(registeredCompetitor); await DeleteResult(registeredCompetitor); return(RedirectToAction(nameof(Index))); }
public RegisteredCompetitor CreateRegisteredCompetitor() { RegisteredCompetitor testRegisteredCompetitor = new RegisteredCompetitor { ParticipantID = 1, CompetitionID = 1, Role = Role.Lead, Placement = Placement.Position1, BibNumber = 100, ChiefJudgeScore = 9, JudgeOneScore = 9, JudgeTwoScore = 9, JudgeThreeScore = 9, JudgeFourScore = 9, JudgeFiveScore = 9, JudgeSixScore = 9, Participant = CreateParticipant(), Competition = CreateCompetition(), EventID = 1 }; return(testRegisteredCompetitor); }
public void CompetitionSet() { RegisteredCompetitor testRegComp = CreateRegisteredCompetitor(); Competition testComp = new Competition { ID = 1, CompType = CompType.Classic }; testRegComp.Competition = testComp; Assert.Equal(testComp, testRegComp.Competition); }
public void ParticipantSet() { RegisteredCompetitor testRegComp = CreateRegisteredCompetitor(); Participant testParticipant = new Participant { ID = 1, FirstName = "Jane", LastName = "Doe" }; testRegComp.Participant = testParticipant; Assert.Equal(testParticipant, testRegComp.Participant); }
public void CompetitionGet() { Competition testComp = new Competition { ID = 1, CompType = CompType.Classic }; RegisteredCompetitor testRegComp = new RegisteredCompetitor { Competition = testComp }; Assert.Equal(testComp, testRegComp.Competition); }
public void ParticipantGet() { Participant testParticipant = new Participant { ID = 1, FirstName = "Jane", LastName = "Doe" }; RegisteredCompetitor testRegComp = new RegisteredCompetitor { Participant = testParticipant }; Assert.Equal(testParticipant, testRegComp.Participant); }
/// <summary> /// Adds new RegisteredCompetitor to db. /// </summary> /// <param name="registeredCompetitor"></param> /// <returns></returns> public async Task CreateRegisteredCompetitor(RegisteredCompetitor registeredCompetitor) { Participant participant = await _context.Participants.FirstOrDefaultAsync(p => p.ID == registeredCompetitor.ParticipantID); registeredCompetitor.Participant = participant; Competition competition = await _context.Competitions.FirstOrDefaultAsync(p => p.ID == registeredCompetitor.CompetitionID); registeredCompetitor.Participant = participant; registeredCompetitor.Competition = competition; _context.RegisteredCompetitors.Add(registeredCompetitor); await _context.SaveChangesAsync(); }
public async void CanSearchRegisteredCompetitor() { DbContextOptions <ClientSideDanceFellowsDbContext> options = new DbContextOptionsBuilder <ClientSideDanceFellowsDbContext>().UseInMemoryDatabase("SearchRegisteredCompetitor").Options; using (ClientSideDanceFellowsDbContext context = new ClientSideDanceFellowsDbContext(options)) { Competition testCompetition = new Competition() { ID = 1, CompType = CompType.Classic, Level = Level.Novice }; Competition testCompetition2 = new Competition() { ID = 2, CompType = CompType.JackAndJill, Level = Level.Advanced }; RegisteredCompetitor testRegisteredCompetitor = new RegisteredCompetitor { ParticipantID = 1, CompetitionID = 1, Role = Role.Lead, Placement = Placement.Position2, BibNumber = 101, ChiefJudgeScore = 8, JudgeOneScore = 8, JudgeTwoScore = 8, JudgeThreeScore = 8, JudgeFourScore = 8, JudgeFiveScore = 8, JudgeSixScore = 8, Competition = testCompetition }; RegisteredCompetitor testRegisteredCompetitor1 = new RegisteredCompetitor { ParticipantID = 2, CompetitionID = 1, Role = Role.Lead, Placement = Placement.Position2, BibNumber = 101, ChiefJudgeScore = 8, JudgeOneScore = 8, JudgeTwoScore = 8, JudgeThreeScore = 8, JudgeFourScore = 8, JudgeFiveScore = 8, JudgeSixScore = 8, Competition = testCompetition }; RegisteredCompetitor testRegisteredCompetitor2 = new RegisteredCompetitor { ParticipantID = 3, CompetitionID = 2, Role = Role.Lead, Placement = Placement.Position2, BibNumber = 101, ChiefJudgeScore = 8, JudgeOneScore = 8, JudgeTwoScore = 8, JudgeThreeScore = 8, JudgeFourScore = 8, JudgeFiveScore = 8, JudgeSixScore = 8, Competition = testCompetition2 }; RegisteredCompetitorManagementService registeredCompetitorService = new RegisteredCompetitorManagementService(context); CompetitionManagementService competitionService = new CompetitionManagementService(context); await competitionService.CreateCompetition(testCompetition); await competitionService.CreateCompetition(testCompetition2); await registeredCompetitorService.CreateRegisteredCompetitor(testRegisteredCompetitor); await registeredCompetitorService.CreateRegisteredCompetitor(testRegisteredCompetitor1); await registeredCompetitorService.CreateRegisteredCompetitor(testRegisteredCompetitor2); IEnumerable <RegisteredCompetitor> expected = new List <RegisteredCompetitor> { testRegisteredCompetitor, testRegisteredCompetitor1 }; IEnumerable <RegisteredCompetitor> actual = await registeredCompetitorService.SearchRegisteredCompetitor("class"); Assert.Equal(expected, actual); } }
public Competition CreateCompetition1() { RegisteredCompetitor testRegisteredCompetitor = new RegisteredCompetitor { CompetitionID = 2, ParticipantID = 2 }; List <RegisteredCompetitor> listRC = new List <RegisteredCompetitor>(); listRC.Add(testRegisteredCompetitor); Competition testCompetition = new Competition() { ID = 2, CompType = CompType.Classic, Level = Level.Novice, RegisteredCompetitors = listRC }; return(testCompetition); }
public Participant CreateParticipant1() { RegisteredCompetitor testRegisteredCompetitor = new RegisteredCompetitor { CompetitionID = 4, ParticipantID = 4 }; List <RegisteredCompetitor> listRC = new List <RegisteredCompetitor>(); listRC.Add(testRegisteredCompetitor); Participant testParticipant = new Participant() { ID = 2, WSC_ID = 1, FirstName = "Ricky", LastName = "Bobby", MinLevel = Level.Novice, MaxLevel = Level.Advanced, EligibleCompetitor = true, RegisteredCompetitors = listRC }; return(testParticipant); }
public void TestRegisteredCompetitorsSet() { Competition testComp = new Competition(); RegisteredCompetitor testCompetitor1 = new RegisteredCompetitor { CompetitionID = 1, ParticipantID = 1 }; RegisteredCompetitor testCompetitor2 = new RegisteredCompetitor { CompetitionID = 1, ParticipantID = 2 }; List <RegisteredCompetitor> competitorList = new List <RegisteredCompetitor>() { testCompetitor1, testCompetitor2 }; testComp.RegisteredCompetitors = competitorList; Assert.Equal(competitorList, testComp.RegisteredCompetitors); }
public async void CanCreateRegisteredCompetitor() { DbContextOptions <ClientSideDanceFellowsDbContext> options = new DbContextOptionsBuilder <ClientSideDanceFellowsDbContext>().UseInMemoryDatabase("CreateRegisteredCompetitor").Options; using (ClientSideDanceFellowsDbContext context = new ClientSideDanceFellowsDbContext(options)) { RegisteredCompetitor testRegisteredCompetitor = CreateRegisteredCompetitor(); RegisteredCompetitorManagementService registeredCompetitorService = new RegisteredCompetitorManagementService(context); await registeredCompetitorService.CreateRegisteredCompetitor(testRegisteredCompetitor); var result = context.RegisteredCompetitors.FirstOrDefault(a => a.ParticipantID == testRegisteredCompetitor.ParticipantID && a.CompetitionID == testRegisteredCompetitor.CompetitionID); Assert.Equal(testRegisteredCompetitor, result); } }
public async Task <IActionResult> Score(int[] participantID, int[] competitionID, Role[] role, int[] bibNumber, int[] chiefJudgeScore, int[] judgeOneScore, int[] judgeTwoScore, int[] judgeThreeScore, int[] judgeFourScore, int[] judgeFiveScore, int[] judgeSixScore) { List <RegisteredCompetitor> roster = new List <RegisteredCompetitor>(); for (int i = 0; i < participantID.Length; i++) { RegisteredCompetitor registeredCompetitor = new RegisteredCompetitor(); registeredCompetitor.ParticipantID = participantID[i]; registeredCompetitor.CompetitionID = competitionID[i]; registeredCompetitor.EventID = 1; registeredCompetitor.Role = role[i]; registeredCompetitor.BibNumber = bibNumber[i]; registeredCompetitor.ChiefJudgeScore = chiefJudgeScore[i]; registeredCompetitor.JudgeOneScore = judgeOneScore[i]; registeredCompetitor.JudgeTwoScore = judgeTwoScore[i]; registeredCompetitor.JudgeThreeScore = judgeThreeScore[i]; registeredCompetitor.JudgeFourScore = judgeFourScore[i]; registeredCompetitor.JudgeFiveScore = judgeFiveScore[i]; registeredCompetitor.JudgeSixScore = judgeSixScore[i]; if (ModelState.IsValid) { await _context.UpdateRegisteredCompetitor(registeredCompetitor); roster.Add(registeredCompetitor); } } await UpdateResult(roster); return(RedirectToAction("Index", "Home")); }
public void TestRegisteredCompetitorsGet() { RegisteredCompetitor testCompetitor1 = new RegisteredCompetitor { CompetitionID = 1, ParticipantID = 1 }; RegisteredCompetitor testCompetitor2 = new RegisteredCompetitor { CompetitionID = 1, ParticipantID = 2 }; List <RegisteredCompetitor> testCompetitors = new List <RegisteredCompetitor>() { testCompetitor1, testCompetitor2 }; Competition testComp = new Competition { RegisteredCompetitors = testCompetitors }; Assert.Same(testCompetitors, testComp.RegisteredCompetitors); }
public async Task <IActionResult> Create([Bind("ParticipantID,CompetitionID,Role,Placement,BibNumber,ChiefJudgeScore,JudgeOneScore,JudgeTwoScore,JudgeThreeScore,JudgeFourScore,JudgeFiveScore,JudgeSixScore,Participant,Competition")] RegisteredCompetitor registeredCompetitor) { var checkDuplicate = await _context.GetRegisteredCompetitor(registeredCompetitor.ParticipantID, registeredCompetitor.CompetitionID); if (checkDuplicate != null) { return(View(checkDuplicate)); } if (ModelState.IsValid) { await _context.CreateRegisteredCompetitor(registeredCompetitor); await CreateResult(registeredCompetitor); return(RedirectToAction(nameof(Index))); } return(View(registeredCompetitor)); }
public async void CanShowCompetition() { DbContextOptions <ClientSideDanceFellowsDbContext> options = new DbContextOptionsBuilder <ClientSideDanceFellowsDbContext>().UseInMemoryDatabase("ShowCompetition").Options; using (ClientSideDanceFellowsDbContext context = new ClientSideDanceFellowsDbContext(options)) { RegisteredCompetitor testRegisteredCompetitor = CreateRegisteredCompetitor(); RegisteredCompetitorManagementService registeredCompetitorService = new RegisteredCompetitorManagementService(context); CompetitionManagementService competitionManagementService = new CompetitionManagementService(context); await competitionManagementService.CreateCompetition(testRegisteredCompetitor.Competition); Competition expected = testRegisteredCompetitor.Competition; Competition actual = await registeredCompetitorService.ShowCompetition(testRegisteredCompetitor.Competition.ID); 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); } }
/// <summary> /// Removes and existing API RegisteredCompetitor. /// </summary> /// <param name="reg"></param> /// <returns>Status Code</returns> private async Task <IActionResult> DeleteResult(RegisteredCompetitor reg) { if (reg == null) { return(NotFound()); } List <object> data = await BuildRegistrationObject(reg); try { HttpResponseMessage response = await client.PostAsJsonAsync(path + "Results/Delete", data); response.EnsureSuccessStatusCode(); Response.StatusCode = 200; return(Ok()); } catch (Exception) { Response.StatusCode = 400; return(NotFound()); } }
public void BibNumberGet() { RegisteredCompetitor testRegComp = CreateRegisteredCompetitor(); Assert.Equal(100, testRegComp.BibNumber); }
public void JudgeSixScoreGet() { RegisteredCompetitor testRegComp = CreateRegisteredCompetitor(); Assert.Equal(9, testRegComp.JudgeSixScore); }