public void AddNewPlayer_9thPlayer_ThrowsError() { var sessionKey = Guid.NewGuid(); var eightPlayers = new List<PlayerEntity>(); var order = new List<PlayerOrder>(); for (int i = 0; i < 8; i++) { var player = new PlayerEntity(); eightPlayers.Add(player); order.Add(new PlayerOrder() { SessionId = 1, Player = player, Value = i }); } var fakeSession = new Session() { Key = sessionKey, ExpirationDate = DateTime.MaxValue, Players = eightPlayers, PlayerOrder = order, }; var fakeContext = LogicalHelpers.GetSimpleSessionContext(fakeSession); var logic = new GameSetupLayer(fakeContext.Object); logic.AddPlayer(sessionKey, LogicalHelpers.GetValidPlayer()); }
public void AddNewPlayer_BadSession_ThrowsErrors() { var fakeSession = new Session() { Key = Guid.NewGuid() }; var sessionKey = Guid.Empty; var fakeContext = LogicalHelpers.GetSimpleSessionContext(fakeSession); var logic = new GameSetupLayer(fakeContext.Object); logic.AddPlayer(sessionKey, LogicalHelpers.GetValidPlayer()); }
public void AddNewPlayer_CompletedSession_ThrowsErrors() { var sessionKey = Guid.NewGuid(); var fakeSession = new Session() { Key = sessionKey, StartDate = DateTime.MinValue, ExpirationDate = DateTime.MinValue, FinishedDate = DateTime.MinValue, }; var fakeContext = LogicalHelpers.GetSimpleSessionContext(fakeSession); var logic = new GameSetupLayer(fakeContext.Object); logic.AddPlayer(sessionKey, LogicalHelpers.GetValidPlayer()); }
public void AddNewPlayer_ExistingSession_AddsPlayerRecords() { var sessionKey = Guid.NewGuid(); var fakeSession = new Session() { Key = sessionKey, ExpirationDate = DateTime.MaxValue, PlayerOrder = new List<PlayerOrder>(), Players = new List<PlayerEntity>(), }; var fakeContext = LogicalHelpers.GetSimpleSessionContext(fakeSession); var logic = new GameSetupLayer(fakeContext.Object); logic.AddPlayer(sessionKey, LogicalHelpers.GetValidPlayer()); Assert.AreNotEqual(0, fakeSession.Players.Count); Assert.AreNotEqual(0, fakeSession.PlayerOrder.Count); }
public void AddNewPlayer_ExistingSession_SavesOnce() { var sessionKey = Guid.NewGuid(); var fakeSession = new Session() { Key = sessionKey, ExpirationDate = DateTime.MaxValue, PlayerOrder = new List<PlayerOrder>(), Players = new List<PlayerEntity>(), }; var fakeContext = LogicalHelpers.GetSimpleSessionContext(fakeSession); var logic = new GameSetupLayer(fakeContext.Object); logic.AddPlayer(sessionKey, LogicalHelpers.GetValidPlayer()); fakeContext.Verify(x => x.SaveChanges(), Times.Exactly(1)); }
public void AddNewPlayer_ExistingSession_DoesntFail() { var sessionKey = Guid.NewGuid(); var fakeSession = new Session() { Key = sessionKey, ExpirationDate = DateTime.MaxValue, PlayerOrder = new List<PlayerOrder>(), Players = new List<PlayerEntity>(), }; var fakeContext = LogicalHelpers.GetSimpleSessionContext(fakeSession); var logic = new GameSetupLayer(fakeContext.Object); logic.AddPlayer(sessionKey, LogicalHelpers.GetValidPlayer()); }