public async Task UserCanBetForAwayTeam(
            Fixture fixture,
            Team homeTeam,
            Team awayTeam,
            Register registerCommand)
        {
            // Arrange
            await _authTestsHelper
            .RegisterAndLogin(registerCommand);

            var match = await _matchTestHelper
                        .RegistrateMatchAsync(fixture, homeTeam, awayTeam);

            var betCommand = new UserBetForAwayTeam
            {
                UserId  = registerCommand.Id,
                MatchId = match.Id,
                AwayBet = fixture.Create <decimal>(),
            };

            // Act
            var result = await _fixture.SendAsync(betCommand);

            // Assert
            var isBetExists = await _fixture.ExecuteDbContextAsync(
                async context =>
                context.UserMatchBets
                .Any(bet => bet.UserId == registerCommand.Id &&
                     bet.MatchId == match.Id &&
                     bet.AwayBet == betCommand.AwayBet &&
                     bet.HomeBet == 0));

            isBetExists.ShouldBeTrue();
        }
예제 #2
0
        public async Task CannotConnectIfNotAManager(Register registerCommand)
        {
            // Arrange
            // The newly registered user is not going to have any roles assigned
            var accessToken = (await _authTestsHelper.RegisterAndLogin(registerCommand)).TokenString;

            var exception = await Should.ThrowAsync <HttpRequestException>(async() =>
            {
                await BuildTestConnection(accessToken)
                .OpenAsync();
            });

            exception.Message.ShouldContain("403");
        }