public async Task ReturnSuccessForValidData() { var gameRepoMock = GamesRepositoryMock.Create(); var rule = new GameOwnerRule(gameRepoMock.Object); var request = new RequestConcrete { GameId = 1, UserId = 1 }; var result = await rule.Validate(request); Assert.NotNull(result); Assert.True(result.IsSuccessful); Assert.Null(result.Error); }
public async Task ReturnFailureForUserOtherThanOwner() { var gameRepoMock = GamesRepositoryMock.Create( isGameOwner: false); var rule = new GameOwnerRule(gameRepoMock.Object); var request = new RequestConcrete { GameId = 1, UserId = 1 }; var result = await rule.Validate(request); Assert.NotNull(result); Assert.False(result.IsSuccessful); Assert.Equal(ValidatorErrors.Games.InvalidUserAction, result.Error); }