Skip to content

Commit

Permalink
Update AwsFileServiceTests.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlirezaEslamikhah committed Dec 28, 2023
1 parent d008d02 commit be8fcbe
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/VakilPors/VakilPors.Test/Core/Services/AwsFileServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Amazon.Runtime;
using Amazon.S3.Internal;
using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces;
using Microsoft.AspNetCore.Mvc;

namespace VakilPors.Test.Core.Services
{
Expand Down Expand Up @@ -95,5 +96,25 @@ public async Task GetFileUrl()
Assert.NotNull(result);
Assert.Equal(sample_output, result);
}

[Fact]
public async Task UploadFileMessageAsync()
{
//Arrange
var key = Guid.NewGuid().ToString();
var request = new PutObjectRequest { Key = key, BucketName = _bucketName, InputStream = null };
var response = new PutObjectResponse { ETag = "sample" };
var formFileMock = new Mock<IFormFile>();
formFileMock.Setup(f => f.Length).Returns(1024);
formFileMock.Setup(f => f.OpenReadStream());
_s3Client.Setup(u => u.PutObjectAsync(It.IsAny<PutObjectRequest>(), It.IsAny<CancellationToken>())).ReturnsAsync(response);

//Act
var result = await awsFileService.UploadFileMessageAsync(formFileMock.Object);
//Assert
Assert.NotNull(result);


}
}
}

0 comments on commit be8fcbe

Please # to comment.