Пример #1
0
        public async Task ChangeNotExistingTokenPayloadTest()
        {
            var dto = new ChangeTokenPayloadDto
            {
                TokenId = "sssssss",
                Payload = "a"
            };

            Assert.ThrowsAsync <NotFoundException>(async() => await _tokenService.ChangePayload(dto));
        }
Пример #2
0
        public async Task ChangeValidPayloadTest()
        {
            var dto = new ChangeTokenPayloadDto
            {
                Payload = "new_payload",
                TokenId = TokenHelper.ValidToken.Id
            };

            var result = await _tokenService.ChangePayload(dto);

            Assert.AreEqual(TokenHelper.ValidToken.Id, result.Id);
        }
Пример #3
0
        public async Task <Contract.Models.Token> ChangePayload(ChangeTokenPayloadDto changeTokenPayloadDto)
        {
            ValidationHelper.ValidateAndThrow(changeTokenPayloadDto);
            if (!await _tokenGetOperations.ExistsById(changeTokenPayloadDto.TokenId))
            {
                throw new NotFoundException("Токен не найден");
            }

            return(await _tokenWriteOperations.UpdatePayload(
                       changeTokenPayloadDto.TokenId,
                       changeTokenPayloadDto.Payload));
        }
Пример #4
0
        public async Task ChangeInvalidTokenPayloadTest()
        {
            var dto = new ChangeTokenPayloadDto();

            Assert.ThrowsAsync <ValidationException>(async() => await _tokenService.ChangePayload(dto));
        }