Example #1
0
        public async Task ReturnSuccessForValidData()
        {
            var gameRepoMock      = GamesRepositoryMock.Create();
            var gameRoundRepoMock = GameRoundsRepositoryMock.Create();
            var playersRepoMock   = PlayersRepositoryMock.Create();

            var rule = new GameOrRoundOwnerRule(gameRepoMock.Object, gameRoundRepoMock.Object, playersRepoMock.Object);

            var request = new RequestConcrete
            {
                GameId      = 1,
                GameRoundId = 1,
                UserId      = 1
            };

            var result = await rule.Validate(request);

            Assert.NotNull(result);
            Assert.True(result.IsSuccessful);
            Assert.Null(result.Error);
        }
Example #2
0
        public async Task ReturnFailureForInvalidUser()
        {
            var gameRepoMock = GamesRepositoryMock.Create(
                isGameOwner: false);
            var gameRoundRepoMock = GameRoundsRepositoryMock.Create(
                isRoundOwner: false);
            var playersRepoMock = PlayersRepositoryMock.Create();

            var rule = new GameOrRoundOwnerRule(gameRepoMock.Object, gameRoundRepoMock.Object, playersRepoMock.Object);

            var request = new RequestConcrete
            {
                GameId      = 1,
                GameRoundId = 1,
                UserId      = 1
            };

            var result = await rule.Validate(request);

            Assert.NotNull(result);
            Assert.False(result.IsSuccessful);
            Assert.Equal(ValidatorErrors.Games.InvalidUserAction, result.Error);
        }