public void CanFindName() { // Arrange const string Team = "Fredrikshof A"; // Act var result = new BitsParser(playersTeamA).Parse(Resources.Id3050651, Team); // Assert Assert.Equal(7, result.TeamScore); }
public void CanParseAlternateAwayTeamName() { // Arrange const string Team = "Fredrikshof A"; // Act var result = new BitsParser(playersTeamA).Parse(Resources.Id3048747, Team); // Assert Assert.Equal(10, result.TeamScore); }
public HttpResponseMessage Get() { var pendingMatches = ExecuteQuery(new GetPendingMatchesQuery()); var registeredMatches = new List<Roster>(); foreach (var pendingMatch in pendingMatches) { try { var players = ExecuteQuery(new GetPlayersQuery(pendingMatch)); var parser = new BitsParser(players); var content = bitsClient.DownloadMatchResult(pendingMatch.BitsMatchId); if (pendingMatch.IsFourPlayer) { var parse4Result = parser.Parse4(content, pendingMatch.Team); ExecuteCommand(new RegisterMatch4Command(pendingMatch, parse4Result)); } else { var parseResult = parser.Parse(content, pendingMatch.Team); ExecuteCommand(new RegisterMatchCommand(pendingMatch, parseResult)); } registeredMatches.Add(pendingMatch); } catch (Exception e) { var message = string.Format("Unable to auto register match {0} ({1})", pendingMatch.Id, pendingMatch.BitsMatchId); ErrorSignal .FromCurrentContext() .Raise(new ApplicationException(message, e)); } } var result = registeredMatches.Select(x => new { x.Date, x.Season, x.Turn, x.BitsMatchId, x.Team, x.Location, x.Opponent }).ToArray(); if (result.Length > 0) return Request.CreateResponse(HttpStatusCode.OK, result); return Request.CreateResponse(HttpStatusCode.OK, "No matches to register"); }
public void CanParseAwayTeam() { // Arrange const string Team = "Trippel XXX"; // Act var result = new BitsParser(awayPlayers).Parse4(Resources.Id3060835, Team); Assert.Equal(1, result.TeamScore); Assert.Equal(18, result.OpponentScore); var series = result.Series; // Assert Assert.Equal(4, series.Length); var serie1 = series[0]; Assert.Equal(4, serie1.Games.Count); VerifyGame(serie1.Games[0], Tuple.Create(1, "player-5", 160)); VerifyGame(serie1.Games[1], Tuple.Create(0, "player-6", 117)); VerifyGame(serie1.Games[2], Tuple.Create(0, "player-7", 139)); VerifyGame(serie1.Games[3], Tuple.Create(0, "player-8", 83)); var serie2 = series[1]; Assert.Equal(4, serie2.Games.Count); VerifyGame(serie2.Games[0], Tuple.Create(0, "player-8", 122)); VerifyGame(serie2.Games[1], Tuple.Create(0, "player-7", 156)); VerifyGame(serie2.Games[2], Tuple.Create(0, "player-6", 101)); VerifyGame(serie2.Games[3], Tuple.Create(0, "player-5", 133)); var serie3 = series[2]; Assert.Equal(4, serie3.Games.Count); VerifyGame(serie3.Games[0], Tuple.Create(0, "player-6", 148)); VerifyGame(serie3.Games[1], Tuple.Create(0, "player-5", 142)); VerifyGame(serie3.Games[2], Tuple.Create(0, "player-9", 118)); VerifyGame(serie3.Games[3], Tuple.Create(0, "player-7", 136)); var serie4 = series[3]; Assert.Equal(4, serie4.Games.Count); VerifyGame(serie4.Games[0], Tuple.Create(0, "player-7", 134)); VerifyGame(serie4.Games[1], Tuple.Create(0, "player-9", 119)); VerifyGame(serie4.Games[2], Tuple.Create(0, "player-5", 122)); VerifyGame(serie4.Games[3], Tuple.Create(0, "player-6", 167)); }
private ActionResult Parse4( RegisterBitsVerifyModel model, BitsParser parser, string content, Roster roster, IEnumerable<Player> players) { Parse4Result result = parser.Parse4(content, roster.Team); var vm = new RegisterBitsResult4 { BitsMatchId = roster.BitsMatchId, TeamScore = result.TeamScore, OpponentScore = result.OpponentScore, RosterId = model.RosterId, Serie1 = result.Series.ElementAtOrDefault(0), Serie2 = result.Series.ElementAtOrDefault(1), Serie3 = result.Series.ElementAtOrDefault(2), Serie4 = result.Series.ElementAtOrDefault(3) }; ViewBag.players = players.Select(x => new PlayerViewModel(x)) .ToArray(); return View("RegisterBitsVerify4", vm); }
public ActionResult RegisterBitsVerify(RegisterBitsVerifyModel model) { if (ModelState.IsValid == false) { ViewBag.rosterid = DocumentSession.CreateRosterSelectList(model.Season); return View("RegisterBits", model); } var roster = DocumentSession.Include<Roster>(r => r.Players) .Load<Roster>(model.RosterId); if (roster == null) throw new HttpException(404, "Roster not found"); var players = roster.Players .Select(x => DocumentSession.Load<Player>(x)) .ToArray(); var parser = new BitsParser(players); var content = bitsClient.DownloadMatchResult(roster.BitsMatchId); if (roster.IsFourPlayer) { var parse4Result = Parse4(model, parser, content, roster, players); return parse4Result; } var parseResult = Parse(model, parser, content, roster, players); return parseResult; }
public void CanParseThreeSeries() { // Arrange const string Team = "Fredrikshof IF"; var players = new[] { new Player("Daniel Solvander", "*****@*****.**", Player.Status.Active) { Id = "player-1" }, new Player("Daniel Lidström", "*****@*****.**", Player.Status.Active) { Id = "player-2" }, new Player("Thomas Gurell", "*****@*****.**", Player.Status.Active) { Id = "player-3" }, new Player("Lennart Axelsson", "*****@*****.**", Player.Status.Active) { Id = "player-4" }, new Player("Håkan Gustavsson", "*****@*****.**", Player.Status.Active) { Id = "player-5" }, new Player("Kjell Johansson", "*****@*****.**", Player.Status.Active) { Id = "player-6" }, new Player("Bengt Solvander", "*****@*****.**", Player.Status.Active) { Id = "player-7" }, new Player("Stefan Traav", "*****@*****.**", Player.Status.Active) { Id = "player-8" }, new Player("Matz Classon", "*****@*****.**", Player.Status.Active) { Id = "player-9" } }; // Act var result = new BitsParser(players).Parse(Resources.Id3067035, Team); Assert.Equal(10, result.TeamScore); Assert.Equal(5, result.OpponentScore); var series = result.Series; // Assert Assert.Equal(3, series.Length); var serie1 = series[0]; Assert.Equal(4, serie1.Tables.Count); VerifyTable(serie1.Tables[0], Tuple.Create(1, "player-1", 200, "player-2", 199)); VerifyTable(serie1.Tables[1], Tuple.Create(1, "player-3", 160, "player-4", 257)); VerifyTable(serie1.Tables[2], Tuple.Create(1, "player-5", 214, "player-6", 195)); VerifyTable(serie1.Tables[3], Tuple.Create(1, "player-7", 175, "player-8", 241)); var serie2 = series[1]; Assert.Equal(4, serie1.Tables.Count); VerifyTable(serie2.Tables[0], Tuple.Create(1, "player-7", 165, "player-8", 217)); VerifyTable(serie2.Tables[1], Tuple.Create(0, "player-5", 180, "player-6", 158)); VerifyTable(serie2.Tables[2], Tuple.Create(0, "player-3", 176, "player-4", 197)); VerifyTable(serie2.Tables[3], Tuple.Create(1, "player-1", 145, "player-2", 161)); var serie3 = series[2]; Assert.Equal(4, serie1.Tables.Count); VerifyTable(serie3.Tables[0], Tuple.Create(0, "player-3", 180, "player-4", 222)); VerifyTable(serie3.Tables[1], Tuple.Create(1, "player-1", 159, "player-2", 277)); VerifyTable(serie3.Tables[2], Tuple.Create(1, "player-7", 166, "player-8", 234)); VerifyTable(serie3.Tables[3], Tuple.Create(0, "player-5", 143, "player-6", 171)); }
public void CanParseHomeTeam() { // Arrange const string Team = "Fredrikshof IF"; // Act var result = new BitsParser(playersTeamA).Parse(Resources.Id3048746, Team); Assert.Equal(11, result.TeamScore); Assert.Equal(9, result.OpponentScore); var series = result.Series; // Assert Assert.Equal(4, series.Length); var serie1 = series[0]; Assert.Equal(4, serie1.Tables.Count); VerifyTable(serie1.Tables[0], Tuple.Create(1, "player-1", 202, "player-2", 219)); VerifyTable(serie1.Tables[1], Tuple.Create(0, "player-3", 203, "player-4", 169)); VerifyTable(serie1.Tables[2], Tuple.Create(1, "player-5", 206, "player-6", 195)); VerifyTable(serie1.Tables[3], Tuple.Create(0, "player-7", 234, "player-8", 165)); var serie2 = series[1]; Assert.Equal(4, serie2.Tables.Count); VerifyTable(serie2.Tables[0], Tuple.Create(1, "player-5", 205, "player-6", 212)); VerifyTable(serie2.Tables[1], Tuple.Create(0, "player-7", 192, "player-8", 192)); VerifyTable(serie2.Tables[2], Tuple.Create(1, "player-1", 212, "player-2", 237)); VerifyTable(serie2.Tables[3], Tuple.Create(1, "player-3", 202, "player-4", 199)); var serie3 = series[2]; Assert.Equal(4, serie3.Tables.Count); VerifyTable(serie3.Tables[0], Tuple.Create(0, "player-7", 206, "player-8", 204)); VerifyTable(serie3.Tables[1], Tuple.Create(1, "player-5", 215, "player-6", 211)); VerifyTable(serie3.Tables[2], Tuple.Create(0, "player-3", 184, "player-4", 172)); VerifyTable(serie3.Tables[3], Tuple.Create(0, "player-1", 175, "player-2", 188)); var serie4 = series[3]; Assert.Equal(4, serie4.Tables.Count); VerifyTable(serie4.Tables[0], Tuple.Create(0, "player-3", 213, "player-9", 173)); VerifyTable(serie4.Tables[1], Tuple.Create(1, "player-1", 188, "player-2", 213)); VerifyTable(serie4.Tables[2], Tuple.Create(1, "player-7", 194, "player-8", 255)); VerifyTable(serie4.Tables[3], Tuple.Create(1, "player-5", 226, "player-6", 210)); }
public void CanParseAwayTeam() { // Arrange const string Team = "Fredrikshof IF"; // Act var result = new BitsParser(playersTeamA).Parse(Resources.Id3048747, Team); Assert.Equal(10, result.TeamScore); Assert.Equal(9, result.OpponentScore); var series = result.Series; // Assert Assert.Equal(4, series.Length); var serie1 = series[0]; Assert.Equal(4, serie1.Tables.Count); VerifyTable(serie1.Tables[0], Tuple.Create(1, "player-3", 202, "player-10", 204)); VerifyTable(serie1.Tables[1], Tuple.Create(0, "player-1", 196, "player-2", 234)); VerifyTable(serie1.Tables[2], Tuple.Create(1, "player-7", 205, "player-8", 247)); VerifyTable(serie1.Tables[3], Tuple.Create(1, "player-5", 227, "player-6", 212)); var serie2 = series[1]; Assert.Equal(4, serie2.Tables.Count); VerifyTable(serie2.Tables[0], Tuple.Create(0, "player-5", 182, "player-6", 213)); VerifyTable(serie2.Tables[1], Tuple.Create(0, "player-7", 226, "player-8", 211)); VerifyTable(serie2.Tables[2], Tuple.Create(1, "player-1", 218, "player-2", 269)); VerifyTable(serie2.Tables[3], Tuple.Create(0, "player-3", 232, "player-10", 162)); var serie3 = series[2]; Assert.Equal(4, serie3.Tables.Count); VerifyTable(serie3.Tables[0], Tuple.Create(0, "player-1", 200, "player-2", 212)); VerifyTable(serie3.Tables[1], Tuple.Create(0, "player-3", 202, "player-10", 201)); VerifyTable(serie3.Tables[2], Tuple.Create(0, "player-5", 202, "player-6", 187)); VerifyTable(serie3.Tables[3], Tuple.Create(1, "player-7", 232, "player-8", 201)); var serie4 = series[3]; Assert.Equal(4, serie4.Tables.Count); VerifyTable(serie4.Tables[0], Tuple.Create(1, "player-7", 217, "player-8", 203)); VerifyTable(serie4.Tables[1], Tuple.Create(1, "player-5", 178, "player-6", 267)); VerifyTable(serie4.Tables[2], Tuple.Create(0, "player-3", 180, "player-10", 229)); VerifyTable(serie4.Tables[3], Tuple.Create(0, "player-1", 183, "player-2", 175)); }
public void CanParseHomeTeam() { // Arrange const string Team = "Fredrikshof B"; // Act var result = new BitsParser(homePlayers).Parse4(Resources.Id3060835, Team); Assert.Equal(18, result.TeamScore); Assert.Equal(1, result.OpponentScore); var series = result.Series; // Assert Assert.Equal(4, series.Length); var serie1 = series[0]; Assert.Equal(4, serie1.Games.Count); VerifyGame(serie1.Games[0], Tuple.Create(0, "player-1", 138)); VerifyGame(serie1.Games[1], Tuple.Create(1, "player-2", 178)); VerifyGame(serie1.Games[2], Tuple.Create(1, "player-3", 183)); VerifyGame(serie1.Games[3], Tuple.Create(1, "player-4", 131)); var serie2 = series[1]; Assert.Equal(4, serie2.Games.Count); VerifyGame(serie2.Games[0], Tuple.Create(1, "player-3", 152)); VerifyGame(serie2.Games[1], Tuple.Create(1, "player-4", 189)); VerifyGame(serie2.Games[2], Tuple.Create(1, "player-1", 205)); VerifyGame(serie2.Games[3], Tuple.Create(1, "player-2", 136)); var serie3 = series[2]; Assert.Equal(4, serie3.Games.Count); VerifyGame(serie3.Games[0], Tuple.Create(1, "player-4", 223)); VerifyGame(serie3.Games[1], Tuple.Create(1, "player-3", 251)); VerifyGame(serie3.Games[2], Tuple.Create(1, "player-2", 158)); VerifyGame(serie3.Games[3], Tuple.Create(1, "player-1", 149)); var serie4 = series[3]; Assert.Equal(4, serie4.Games.Count); VerifyGame(serie4.Games[0], Tuple.Create(1, "player-2", 179)); VerifyGame(serie4.Games[1], Tuple.Create(1, "player-1", 181)); VerifyGame(serie4.Games[2], Tuple.Create(1, "player-4", 183)); VerifyGame(serie4.Games[3], Tuple.Create(0, "player-3", 167)); }