public void PlayerThatHasSessionHasToDeleteCurrentSession() { var playerId = Guid.NewGuid().ToString(); A.CallTo(() => _readSessionRepository.GetCurrentSessionForPlayer(A <string> ._)).Returns(new Session(playerId, Guid.NewGuid().ToString())); var sessionId = _command.Execute(playerId); Assert.False(sessionId == Session.Empty.SessionId); A.CallTo(() => _writeSessionRepository.RemoveSession(A <string> ._)).MustHaveHappened(); }
public string Execute(string playerId) { if (string.IsNullOrWhiteSpace(playerId)) { return(Session.Empty.SessionId); } var currentSession = _readSessionRepository.GetCurrentSessionForPlayer(playerId); if (!currentSession.IsEmpty) { _writeSessionRepository.RemoveSession(currentSession.SessionId); } var session = new Session(playerId); _writeSessionRepository.CreateSession(session); return(session.SessionId); }