public async Task ReturnFailureForInvalidRoundStatus() { var baseMock = BaseGameRequestsValidatorMock.CreateMock(); var playersRepo = PlayersRepositoryMock.Create().Object; var gameRoundRepo = GameRoundsRepositoryMock.Create( status: Common.Enums.GameRoundStatusEnum.Finished).Object; var gameOrRoundOnwerRuleMock = GameOrRoundOwnerRuleMock.Create <StartGameRound>(); var validator = new StartGameRoundValidator(baseMock.Object, playersRepo, gameRoundRepo, gameOrRoundOnwerRuleMock.Object); var request = new StartGameRound { GameRoundId = 1, UserId = 1, GameId = 1 }; var result = await validator.Validate(request); Assert.False(result.IsSuccessful); Assert.Equal(ValidatorErrors.Games.InvalidGameRoundStatus, result.Error); }
public async Task ReturnSuccessForValidData() { var baseMock = BaseGameRequestsValidatorMock.CreateMock(); var playersRepo = PlayersRepositoryMock.Create().Object; var gameRoundRepo = GameRoundsRepositoryMock.Create( status: Common.Enums.GameRoundStatusEnum.Pending).Object; var gameOrRoundOnwerRuleMock = GameOrRoundOwnerRuleMock.Create <StartGameRound>(); var validator = new StartGameRoundValidator(baseMock.Object, playersRepo, gameRoundRepo, gameOrRoundOnwerRuleMock.Object); var request = new StartGameRound { GameRoundId = 1, UserId = 1, GameId = 1 }; var result = await validator.Validate(request); Assert.True(result.IsSuccessful); baseMock.Verify(x => x.Validate(request)); gameOrRoundOnwerRuleMock.Verify(x => x.Validate(request)); }