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_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 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 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 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)); }