public async Task ReturnFailureForUserThatAlreadyJoined() { var baseMock = BaseGameRequestsValidatorMock.CreateMock(); var gameRepo = GamesRepositoryMock.Create().Object; var playersRepo = PlayersRepositoryMock.Create( playerExists: true).Object; var validator = new JoinGameValidator(baseMock.Object, gameRepo, playersRepo); var request = new JoinGame { GameId = 1, UserId = 1 }; var result = await validator.Validate(request); Assert.False(result.IsSuccessful); Assert.Equal(ValidatorErrors.Games.UserAlreadyJoined, result.Error); }
public async Task ReturnSuccessForValidData() { var baseMock = BaseGameRequestsValidatorMock.CreateMock(); var gameRepo = GamesRepositoryMock.Create().Object; var playersRepo = PlayersRepositoryMock.Create( playerExists: false).Object; var validator = new JoinGameValidator(baseMock.Object, gameRepo, playersRepo); var request = new JoinGame { GameId = 1, UserId = 1 }; var result = await validator.Validate(request); Assert.True(result.IsSuccessful); baseMock.Verify(x => x.Validate(request)); }