public void Competition_Invoice_Test() { var fortKnox = FortKnox.Instance(); var invoices = fortKnox.ExportInvoices(); Assert.Empty(invoices); var memberFactory = new MemberFactory(400); var member1 = memberFactory.CreateMember("Test1", "1", true); var member2 = memberFactory.CreateMember("Test2", "2", true); var competitionFactory = new CompetitionFactory(); var testCompetition = competitionFactory.CreateCompetition("Test Cup", DateTime.Now, DateTime.Now.AddDays(7), 150); var matchDirector = new MatchDirector(); var competitionMatchBuilder = new CompetitionMatchBuilder(testCompetition, 100); matchDirector.Construct(competitionMatchBuilder, member1, member2); var expectedInvoice1 = "Name: " + member1.Name + " Address: " + member1.Address + " Amount: " + 100; var expectedInvoice2 = "Name: " + member2.Name + " Address: " + member2.Address + " Amount: " + 100; var expectedInvoice3 = "Name: " + member1.Name + " Address: " + member1.Address + " Amount: " + 150; var expectedInvoice4 = "Name: " + member2.Name + " Address: " + member2.Address + " Amount: " + 150; invoices = fortKnox.ExportInvoices(); Assert.Contains(expectedInvoice1, invoices); Assert.Contains(expectedInvoice2, invoices); Assert.Contains(expectedInvoice1, invoices); Assert.Contains(expectedInvoice2, invoices); }
public void Competition_Champion_Not_Enough_Matches_Test() { var resultManager = ResultManager.Instance(); var memberFactory = new MemberFactory(400); var member1 = memberFactory.CreateMember("Test", "Test street 1", true); var member2 = memberFactory.CreateMember("tester", "tester street 55", true); var competitionFactory = new CompetitionFactory(); var testCompetition = competitionFactory.CreateCompetition("Test Cup", DateTime.Now, DateTime.Now.AddDays(7), 150); var matchDirector = new MatchDirector(); var competitionMatchBuilder = new CompetitionMatchBuilder(testCompetition, 100); for (var i = 0; i < 9; i++) { matchDirector.Construct(competitionMatchBuilder, member1, member2); competitionMatchBuilder.GetResult().SetPlayerOneScore(50, 50, 50); competitionMatchBuilder.GetResult().SetPlayerTwoScore(100, 100, 100); } Assert.Null(resultManager.GetCompetitionResults(testCompetition)); }
private void btnCompetitionAdd_Click(object sender, EventArgs e) { #if BETA if (FTournament.Competitions.Count >= EditionManager.MaxTournamentCount) { WindowSkin.MessageBox.Show(Localizator.Dictionary.GetString("BETA_LIMIT_COMPETITIONS")); return; } #endif CompetitionInfo info = new CompetitionInfo(); info.TournamentId = FTournament.Info.Id; info.Date = FTournament.Info.DateBegin; if (fCompetitionInfo.Edit(info)) { Competition competition = CompetitionFactory.CreateCompetition(info); DatabaseManager.CurrentDb.CompetitionInfoSave(competition.Info); FTournament.Competitions.Add(competition.Info.Id, competition); fCompetition.Edit(competition); } UpdateCompetitionGrid(); }
static void Main(string[] args) { var memberFactory = new MemberFactory(400); for (var i = 0; i < 11; i++) { memberFactory.CreateMember("TestMember" + i, "Test Street" + i, true); } var competitionFactory = new CompetitionFactory(); var testCompetition = competitionFactory.CreateCompetition("Test Competition", DateTime.Now, DateTime.Now.AddDays(7), 150); var matchDirector = new MatchDirector(); var testCupGameMatchBuilder = new CompetitionMatchBuilder(testCompetition, 100); Console.WriteLine("Competition games"); for (var j = 0; j < 11; j++) { for (var i = j + 1; i < 11; i++) { var player = ResultManager.Instance().Members[j]; var opponent = ResultManager.Instance().Members[i]; matchDirector.Construct(testCupGameMatchBuilder, player, opponent); testCupGameMatchBuilder.GetResult().GeneratePlayerScores(); } } Console.WriteLine(); Console.WriteLine("Champion playing games..."); var champ = memberFactory.CreateMember("Winner", "Winner Street", true); var loser = memberFactory.CreateMember("Loser", "Loser Street", true); var standaloneMatchBuilder = new MatchBuilder(100); for (var i = 0; i < 12; i++) { matchDirector.Construct(standaloneMatchBuilder, champ, loser); var testMatch = standaloneMatchBuilder.GetResult(); testMatch.SetPlayerOneScore(100, 100, 100); testMatch.SetPlayerTwoScore(50, 50, 50); } var resultManager = ResultManager.Instance(); resultManager.GetCompetitionResults(testCompetition); resultManager.GetYearChampion(DateTime.Now); Console.WriteLine(); Console.WriteLine("----------"); var fortKnox = FortKnox.Instance(); fortKnox.ExportInvoices(); Console.WriteLine("Press any key..."); Console.ReadLine(); }