public async Task AddFileByUrlAsyncShouldExecuteRepositoryCreateAsync()
        {
            // Arrange
            var filePath     = "https://filesamples.com/samples/document/txt/sample3.txt";
            var resultString = "Quod equidem non reprehendo;";
            var val          = Guid.NewGuid();
            var textEntity   = new TextEntity {
                Id = val, TextValue = resultString
            };
            var textFile = new TextFile()
            {
                Id = val, TextValue = resultString
            };
            CancellationTokenSource cancelTokenSource = new CancellationTokenSource();
            CancellationToken       token             = cancelTokenSource.Token;

            _textRepository.Setup(x => x.CreateAsync(It.IsAny <TextEntity>())).ReturnsAsync(textEntity);
            _mapper.Setup(m => m.Map <TextFile>(It.IsAny <TextEntity>())).Returns(textFile);

            // Act
            var result = await _textService.AddFileByUrlAsync(filePath, token);

            // Assert
            Assert.NotNull(result);
            Assert.IsType <TextFile>(result);
            Assert.Equal(textFile.TextValue, result.TextValue);
        }
Example #2
0
        public async Task <ActionResult <TextFile> > PostFileUrl([FromBody] string textFileUrl, CancellationToken cancellationToken)
        {
            var bearerToken = Request.Headers["Authorization"];

            _logger.LogInformation($"PostFileUrl: {bearerToken} {DateTime.Now}");
            var textFile = await _textService.AddFileByUrlAsync(textFileUrl, cancellationToken);

            return(new OkObjectResult(textFile));
        }
Example #3
0
        public async Task <ActionResult <TextFile> > PostFileUrl([FromBody] string textFileUrl, CancellationToken cancellationToken)
        {
            var textFile = await _textService.AddFileByUrlAsync(textFileUrl, cancellationToken);

            return(new OkObjectResult(textFile));
        }