Esempio n. 1
0
        public async Task ReturnSuccessForValidData()
        {
            var gameRoundRepoMock = GameRoundsRepositoryMock.Create();
            var playersRepoMock   = PlayersRepositoryMock.Create();

            var rule = new RoundOwnerRule(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);
        }
Esempio n. 2
0
        public async Task ReturnFailureForInvalidUser()
        {
            var gameRoundRepoMock = GameRoundsRepositoryMock.Create(
                isRoundOwner: false);
            var playersRepoMock = PlayersRepositoryMock.Create();

            var rule = new RoundOwnerRule(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);
        }