public void Draw_ReturnsWinner() { // Arrange var drawService = new DrawService(); drawService.AddParticipant("participant_one"); drawService.AddParticipant("participant_two"); drawService.AddParticipant("participant_three"); // Act var winner = drawService.Draw(); // Assert Assert.Contains(drawService.GetParticipants(), _ => _.Contains(winner)); }
public void Update() { while (true) { foreach (var drop in Rain) { drop.Fall(); _drawService.Draw(Rain, Form); if (drop.Y > Form.Height) { drop.DefaultValues(_random.Next(-200, -100), _random.Next(4, 10)); } } } }
/// <summary> /// Basic drawing. /// The draw control becomes updated though invalidation: <see cref="System.Windows.Forms.Control.Invalidate()"/> /// </summary> protected override void Draw() { if (_Editor != null) { UpdateMousePositions(); Editor.UpdateMousePositions(GetRelativeMousePosition, GetAbsoluteMousePosition); Editor.IsMouseInsideControl = IsMouseInsideControl; _Editor.Draw(); if (AutomaticInvalidation) { Invalidate(); } } }
/// <summary> /// Ход игры /// </summary> public JsonResult Turn(int?turnNum) { GameState gameState = Session["test"] as GameState; if (gameState == null) { return(Json(new { error = true })); } string prevBoardStr = JsonHelper.SerialiazeWithType(gameState.board); if (gameState.game.CurrentPlayer is WebHumanPlayer) { if (turnNum.HasValue) { gameState.game.CurrentPlayer.SetHumanMove(turnNum.Value); gameState.game.Turn(); } else { // если пользователь не сделал выбор, то перезапрашиваем ход } } else { gameState.game.Turn(); } var prevBoard = JsonHelper.DeserialiazeWithType <Board>(prevBoardStr); var service = new DrawService(); return(Json(new { changes = service.Draw(gameState.board, prevBoard), stat = service.GetStatistics(gameState.game), moves = service.GetAvailableMoves(gameState.game) })); }