Esempio n. 1
0
        public async Task Should_throw_CannotJoinGameException()
        {
            var context = DbContextFactory.CreateTripleTriadContext();
            var game    = CreateGame();

            game.ChallengerId = Guid.NewGuid();

            await context.Games.AddAsync(game);

            await context.SaveChangesAsync();

            var command = new GameJoin.Request()
            {
                GameId   = GameId,
                PlayerId = PlayerId
            };

            var subject = new GameJoin.RequestHandler(context);

            Func <Task> act = async() => await subject.Handle(command, default);

            act.Should()
            .Throw <CannotJoinGameException>()
            .Where(e => e.GameId == GameId);
        }
Esempio n. 2
0
        public void Should_throw_GameNotFoundException()
        {
            var gameId  = 1;
            var context = DbContextFactory.CreateTripleTriadContext();

            var command = new GameJoin.Request()
            {
                GameId   = gameId,
                PlayerId = PlayerId
            };
            var subject = new GameJoin.RequestHandler(context);

            Func <Task> act = async() => await subject.Handle(command, default);

            act.Should()
            .Throw <GameNotFoundException>()
            .Where(e => e.GameId == gameId);
        }
Esempio n. 3
0
        public async Task Should_return_joined_game()
        {
            var context = DbContextFactory.CreateTripleTriadContext();
            var game    = CreateGame();

            await context.Games.AddAsync(game);

            await context.SaveChangesAsync();

            var command = new GameJoin.Request()
            {
                GameId   = GameId,
                PlayerId = PlayerId
            };
            var subject = new GameJoin.RequestHandler(context);

            var response = await subject.Handle(command, default);

            response.GameId.Should().Be(GameId);
        }
Esempio n. 4
0
        public async Task Should_set_game_status_to_choose_cards()
        {
            var context = DbContextFactory.CreateTripleTriadContext();
            var game    = CreateGame();

            await context.Games.AddAsync(game);

            await context.SaveChangesAsync();

            var command = new GameJoin.Request()
            {
                GameId   = GameId,
                PlayerId = PlayerId
            };
            var subject = new GameJoin.RequestHandler(context);

            var response = await subject.Handle(command, default);

            game = await context.Games.SingleAsync(x => x.GameId == response.GameId);

            game.Status.Should().Be(GameStatus.ChooseCards);
        }
Esempio n. 5
0
        public async Task Should_have_correct_player_two_id()
        {
            var context = DbContextFactory.CreateTripleTriadContext();
            var game    = CreateGame();

            await context.Games.AddAsync(game);

            await context.SaveChangesAsync();

            var command = new GameJoin.Request()
            {
                GameId   = GameId,
                PlayerId = PlayerId
            };
            var subject = new GameJoin.RequestHandler(context);

            var response = await subject.Handle(command, default);

            game = await context.Games.SingleAsync(x => x.GameId == response.GameId);

            game.ChallengerId.Should().Be(PlayerId);
        }