Esempio n. 1
0
        public void Test_StartSession_ReturnsIdForSession()
        {
            var gameId = 6667;

            var game = new Game()
            {
                Id = gameId
            };

            _mockGameStorage.GetSingle(game.Id).Returns(game.Some());

            var errands = Enumerable.Range(1, 6).Select(i => new Errand {
                Id = i, Description = "Errand " + i
            });

            _mockGameErrandStorage.GetForGame(game.Id).Returns(errands);

            var guid = Guid.NewGuid();

            _mockGameSessionStorage.CreateSession(game, errands).Returns(guid);

            var result = _service.StartSession(gameId);

            Assert.AreEqual(guid, result);
        }
Esempio n. 2
0
        public Guid StartSession(long gameId)
        {
            var game = _gameStorage
                       .GetSingle(gameId)
                       .ValueOrFailure($"No game exists with ID {gameId}");

            var errands   = _gameErrandStorage.GetForGame(gameId);
            var sessionId = _gameSessionStorage.CreateSession(game, errands);
            var newEvent  = new SessionCreatedEvent(sessionId, errands.Count());

            _gameSessionEvents.OnNext(newEvent);
            _gameSessionEventStorage.AddEvent(sessionId, newEvent);
            return(sessionId);
        }