Ejemplo n.º 1
0
        public async Task UploadFile_When_Missing_File_Content_Returns_BadRequest_With_Error_Message()
        {
            var fixture = new Fixture();
            var url     = $"http://localhost";

            _httpClient.DefaultRequestHeaders.Add("Authorization",
                                                  $"Bearer {TestsHelper.GetSuperUserAuthenticationToken()}");
            var uploadFileRequest = new UploadFileRequest
            {
                PathFile = $"/{fixture.Create<string>()}.xls",
            };

            var result = await _httpClient.PostAsync(url, CreateUploadFileRequestContent(uploadFileRequest));

            Assert.NotNull(result);
            Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode);
            var resultContent = await result.Content.ReadAsStringAsync();

            Assert.Equal(StorageProviderError.MissingFileContent.ToString(), resultContent.Replace("\"", string.Empty));
        }
Ejemplo n.º 2
0
        public async Task UploadFile_When_Storage_Provider_Fails_Returns_InternalServerError()
        {
            var fixture = new Fixture();
            var url     = $"http://localhost";

            _httpClient.DefaultRequestHeaders.Add("Authorization",
                                                  $"Bearer {TestsHelper.GetSuperUserAuthenticationToken()}");
            var uploadFileRequest = new UploadFileRequest
            {
                PathFile = $"/{fixture.Create<string>()}.xls",
                Content  = fixture.Create <byte[]>()
            };

            _amazonS3.Setup(s => s.PutObjectAsync(It.IsAny <PutObjectRequest>(), It.IsAny <CancellationToken>()))
            .ThrowsAsync(new Exception());

            var result = await _httpClient.PostAsync(url, CreateUploadFileRequestContent(uploadFileRequest));

            Assert.NotNull(result);
            Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
        }