public void GetPlayerSeed_ReturnsCorrectSeedValue() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 8; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i * 10); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); Assert.AreEqual(3, b.GetPlayerSeed(30)); }
public void NumberOfRounds_ReturnsNumber() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 4; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); Assert.AreEqual(2, b.NumberOfRounds); }
public void GetRound_ReturnsCorrectMatchList() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 8; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); Assert.AreEqual(4, b.GetRound(1).Count); }
public void AddPlayer_ThrowsArgNullExcept_OnNullParam() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 2; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.AddPlayer(null); Assert.AreEqual(1, 2); }
public void ReplacePlayer_ThrowsInvalidIndex_WithBadIndexParam() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 4; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.ReplacePlayer(new Mock <IPlayer>().Object, 6); Assert.AreEqual(1, 2); }
public void SetNewPlayerlist_ReplacesOldPlayerlistWithNew() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 12; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList.Where(p => p.Id <= 8).ToList()); b.SetNewPlayerlist(pList.Where(p => p.Id > 8).ToList()); Assert.AreEqual(4, b.Players.Count); }
public void SetNewPlayerlist_ThrowsNullReferenceWithNullParam() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 8; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.SetNewPlayerlist(null); Assert.AreEqual(1, 2); }
public void ReinsertPlayer_ThrowsInvalidIndex_WithBadIndexInput() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 8; ++i) { var moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.ReinsertPlayer(2, -2); Assert.AreEqual(1, 2); }
public void GetMatch_ThrowsInvalidIndex_WithNegativeParam() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 4; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); var m = b.GetMatch(-1); Assert.AreEqual(1, 2); }
public void GetMatch_ThrowsNotFound_IfMatchNumberNotFound() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 4; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); var m = b.GetMatch(15); Assert.AreEqual(1, 2); }
public void SMGFWR_ThrowsScoreExcept_IfInputIsNegative() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 4; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.SetMaxGamesForWholeRound(1, 0); Assert.AreEqual(1, 2); }
public void SwapPlayers_ThrowsInvalidIndexWithBadParameter() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 8; ++i) { var moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.SwapPlayers(0, -2); Assert.AreEqual(1, 2); }
public void GetMatch_ReturnsCorrectMatch() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 4; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); IMatch m = b.GetMatch(2); Assert.AreEqual(1, m.Players[(int)PlayerSlot.Defender].Id); }
public void ResetPlayers_ClearsPlayerList() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 4; ++i) { var moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.ResetPlayers(); Assert.AreEqual(0, b.Players.Count); }
public void RandomizeSeeds_Randomizes_ThisIsJustForDebugging() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 8; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i * 10); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.RandomizeSeeds(); Assert.AreEqual(2, 2); }
public void GetPlayerSeed_ThrowsNotFoundWithBadIDInput() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 8; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i * 10); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.GetPlayerSeed(11); Assert.AreEqual(3, 2); }
public void RemovePlayer_ThrowsNotFound_IfPlayerIsntPresent() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 4; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.RemovePlayer(-5); Assert.AreEqual(1, 2); }
public void SMGFWR_ThrowsInactiveMatch_IfAffectedMatchIsFinished() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 4; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.AddGame(2, 1, 0, PlayerSlot.Defender); b.SetMaxGamesForWholeRound(1, 3); Assert.AreEqual(1, 2); }
public void ReinsertPlayer_MovesPlayerDownwardToDestinationSlot() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 8; ++i) { var moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); int playerId = b.Players[2].Id; b.ReinsertPlayer(2, 6); Assert.AreEqual(playerId, b.Players[6].Id); }
public void AddPlayer_ResetsBracketMatches() { IPlayer ip = new Mock <IPlayer>().Object; List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 2; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.AddPlayer(ip); Assert.AreEqual(0, b.NumberOfMatches); }
public void SMGFWR_UpdatesSingleElimBrackets() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 16; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); int games = 5; b.SetMaxGamesForWholeRound(2, games); Assert.AreEqual(games, b.GetRound(2)[1].MaxGames); }
public void ReinsertPlayer_ShiftsAffectedPlayersUpward() { List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 8; ++i) { var moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); int playerId = b.Players[5].Id; b.ReinsertPlayer(2, 6); Assert.AreEqual(playerId, b.Players[4].Id); }
public void AddPlayer_ThrowsDuplicate_OnTryingToAddTwice() { IPlayer ip = new Mock <IPlayer>().Object; List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 2; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.AddPlayer(ip); b.AddPlayer(ip); Assert.AreEqual(1, 2); }
public void AddPlayer_Adds() { Mock <IPlayer> m = new Mock <IPlayer>(); m.Setup(p => p.Id).Returns(10); List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 2; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.AddPlayer(m.Object); Assert.IsTrue(b.Players.Contains(m.Object)); }
public void ReplacePlayer_Replaces() { IPlayer ip = new Mock <IPlayer>().Object; List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 4; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); int pIndex = 2; b.ReplacePlayer(ip, pIndex); Assert.AreEqual(ip, b.Players[pIndex]); }
public void RemovePlayer_Removes() { var ip = new Mock <IPlayer>(); ip.Setup(p => p.Id).Returns(10); List <IPlayer> pList = new List <IPlayer>(); for (int i = 0; i < 4; ++i) { Mock <IPlayer> moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); b.AddPlayer(ip.Object); b.RemovePlayer(ip.Object.Id); Assert.IsFalse(b.Players.Contains(ip.Object)); }
public void SwapPlayers_Swaps() { int i1 = 1; int i2 = 6; List <IPlayer> pList = new List <IPlayer>(); for (int i = 1; i <= 8; ++i) { var moq = new Mock <IPlayer>(); moq.Setup(p => p.Id).Returns(i); pList.Add(moq.Object); } IBracket b = new SingleElimBracket(pList); int playerId = b.Players[i1].Id; b.SwapPlayers(i1, i2); Assert.AreEqual(playerId, b.Players[i2].Id); }