public void FirstNameTest() { Player target = new Player(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; target.FirstName = expected; actual = target.FirstName; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void GamesTest() { Player target = new Player(); // TODO: Initialize to an appropriate value List<Game> expected = null; // TODO: Initialize to an appropriate value List<Game> actual; target.Games = expected; actual = target.Games; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void AddPlayer(Player player) { //Possible other validation to add a new Player, eg. first name and last name already exist. //A player must have a first name. Does a player must have a last name in order to play? if ((!DoesPlayerExistInTournament(player)) && (DoesPlayerHasNames(player))) { Players.Add(player); log.Debug("Player " + player.FirstName + " has been added to the tournament"); } }
public void CalculateDifferencePlayedAgainstPlayerTest() { Player target = new Player(); // TODO: Initialize to an appropriate value Player player = null; // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.CalculateDifferencePlayedAgainstPlayer(player); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public Game(Player wPlayer, Player bPlayer) { this.WhitePlayer = wPlayer; this.BlackPlayer = bPlayer; //When a new game has been created, we set it immediatly to 'IsInProgress' IsInProgress = true; WhitePlayer.Games.Add(this); WhitePlayer.WhiteBlackBalance++; BlackPlayer.WhiteBlackBalance--; BlackPlayer.Games.Add(this); }
public void IsReadyToPlayTest() { Player target = new Player(); // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; target.IsReadyToPlay = expected; actual = target.IsReadyToPlay; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void WhiteBlackBalanceTest() { Player target = new Player(); // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; target.WhiteBlackBalance = expected; actual = target.WhiteBlackBalance; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void PointsTest() { Player target = new Player(); // TODO: Initialize to an appropriate value double expected = 0F; // TODO: Initialize to an appropriate value double actual; target.Points = expected; actual = target.Points; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void TestAddValidPlayerToTournament() { Player player = new Player("Pol","De Bakker"); Tournament.AddPlayer(player); Assert.IsTrue(Tournament.Players.Contains(player)); }
public void PlayerConstructorTest() { string firstName = string.Empty; // TODO: Initialize to an appropriate value string lastName = string.Empty; // TODO: Initialize to an appropriate value Player target = new Player(firstName, lastName); Assert.Inconclusive("TODO: Implement code to verify target"); }
/// <summary> /// Current rules for adding a new player: /// - Player must have a first name and a last name. (Can be changed later to first name only eventually). /// - Player first name and last name combination must be unique in the tournament. /// </summary> /// <param name="player"></param> /// <returns></returns> public bool DoesPlayerExistInTournament(Player player) { return Players.Any(p => p.FirstName.Equals(player.FirstName, StringComparison.InvariantCultureIgnoreCase) && p.LastName.Equals(player.LastName, StringComparison.InvariantCultureIgnoreCase)); }
private bool DoesPlayerHasNames(Player player) { if (string.IsNullOrEmpty(player.FirstName) || string.IsNullOrEmpty(player.LastName)) { return false; } else return true; }
/// <summary> /// Determines who will play with white and black. /// </summary> /// <param name="playerA">The first player</param> /// <param name="playerB">The second player</param> /// <returns>An array of Players, where Player[0] is white and Player[1] is black.</returns> private Player[] DeterminePlayerColor(Player playerA, Player playerB) { Player[] players = new Player[2]; if(playerA.WhiteBlackBalance < playerB.WhiteBlackBalance) { players[0] = playerA; players[1] = playerB; } if(playerA.WhiteBlackBalance > playerB.WhiteBlackBalance) { players[0] = playerB; players[1] = playerA; } if(playerA.WhiteBlackBalance == playerB.WhiteBlackBalance) { List<Player> playersSorted = Players.OrderByDescending(player => player.Points).ToList(); if (playersSorted.IndexOf(playerB) < playersSorted.IndexOf(playerA)) { players[0] = playerA; players[1] = playerB; } else { players[0] = playerB; players[1] = playerA; } } return players; }
//Check of the two domain rules (see constants above) //TODO Move method to Models/Player private bool CanPlayAgainstPlayer(Player worstInRank, Player betterInRank) { List<Player> players = Players.OrderByDescending(player => player.Points).ToList(); //The last check is too see if the players played already against each other if (((players.IndexOf(worstInRank) - players.IndexOf(betterInRank)) < MaxPositionsRemovedFromOtherPlayer) && worstInRank.CalculateDifferencePlayedAgainstPlayer(betterInRank) > LastTimePlayedAgainstOtherPlayer && worstInRank != betterInRank) { return true; } else return false; }
/// <summary> /// Calculates the number of games difference between now and when the players have played last time. Initial value is 1000, which is practically impossible. /// </summary> /// <returns>The number of games ago this player has played against the parameter player</returns> public int CalculateDifferencePlayedAgainstPlayer(Player player) { int value = 1000; for (int i = 0; i < Games.Count; i++) { Game currentGame = Games.ElementAt(i); if(currentGame.WhitePlayer.Equals(player) || currentGame.BlackPlayer.Equals(player)) { value = i; break; } } return value; }
public PlayerViewModel(Player player) { this.Player = player; Messenger.Default.Register<NotificationMessage>(this, NotificationMessageReceived); }
public void PlayerConstructorTest1() { Player target = new Player(); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void TestAddEmptyPlayerToTournament() { Player player = new Player(); Tournament.AddPlayer(player); Assert.IsFalse(Tournament.Players.Contains(player)); }