Exemple #1
0
        /// <summary>
        /// Permet de récupérer un RefreshToken via sa valeur et l'id d'un utilisateur
        /// </summary>
        /// <param name="token"></param>
        /// <param name="userId"></param>
        /// <returns>RefreshToken</returns>
        public async Task <RefreshToken> GetRefreshTokenByValueAndUserId(string token, string userId)
        {
            RefreshToken refreshToken = null;

            if (!String.IsNullOrWhiteSpace(token) && !String.IsNullOrWhiteSpace(userId))
            {
                refreshToken = await _repo.GetRefreshTokenByValueAndUserId(token, userId);
            }

            return(refreshToken);
        }
        public async void GetRefreshTokenByValueAndUserIdWithRightValueAndUserId()
        {
            string tokenValue = "tokenValue";
            string userId     = "id";
            var    token      = new RefreshToken
            {
                TokenValue = tokenValue,
                UserId     = userId
            };

            _repo.GetRefreshTokenByValueAndUserId(tokenValue, userId).Returns(token);

            RefreshTokenService refreshService = new RefreshTokenService(_repo);

            var result = await refreshService.GetRefreshTokenByValueAndUserId(tokenValue, userId);

            Assert.NotNull(result);
            Assert.IsType <RefreshToken>(result);
            Assert.NotNull(result.TokenValue);
            Assert.NotNull(result.UserId);
            Assert.Equal(result.TokenValue, tokenValue);
            Assert.Equal(result.UserId, userId);
        }