diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index a8006fb..13db036 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -16,8 +16,7 @@ on: workflow_dispatch: push: branches: - - 'master' - - 'develop' + - '*' jobs: build: diff --git a/FileSystem.Adapters.AmazonS3/src/AmazonS3Adapter.cs b/FileSystem.Adapters.AmazonS3/src/AmazonS3Adapter.cs index a997aa5..67c33f0 100644 --- a/FileSystem.Adapters.AmazonS3/src/AmazonS3Adapter.cs +++ b/FileSystem.Adapters.AmazonS3/src/AmazonS3Adapter.cs @@ -15,10 +15,10 @@ namespace SharpGrip.FileSystem.Adapters.AmazonS3 { public class AmazonS3Adapter : Adapter { - private readonly AmazonS3Client client; + private readonly IAmazonS3 client; private readonly string bucketName; - public AmazonS3Adapter(string prefix, string rootPath, AmazonS3Client client, string bucketName) : base(prefix, rootPath) + public AmazonS3Adapter(string prefix, string rootPath, IAmazonS3 client, string bucketName) : base(prefix, rootPath) { this.client = client; this.bucketName = bucketName; diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 77e7fe8..7264d21 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -8,7 +8,11 @@ - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + all diff --git a/Tests/src/FileSystem.Adapters.AmazonS3/AmazonS3AdapterTest.cs b/Tests/src/FileSystem.Adapters.AmazonS3/AmazonS3AdapterTest.cs index 41fdded..9f7838e 100644 --- a/Tests/src/FileSystem.Adapters.AmazonS3/AmazonS3AdapterTest.cs +++ b/Tests/src/FileSystem.Adapters.AmazonS3/AmazonS3AdapterTest.cs @@ -1,9 +1,8 @@ using System; using System.Threading.Tasks; -using Amazon; using Amazon.S3; using Amazon.S3.Model; -using Moq; +using NSubstitute; using SharpGrip.FileSystem.Adapters.AmazonS3; using SharpGrip.FileSystem.Models; using Xunit; @@ -15,8 +14,8 @@ public class AmazonS3AdapterTest [Fact] public void Test_Instantiation() { - var amazonS3Client = new Mock("awsAccessKeyId", "awsSecretAccessKey", RegionEndpoint.USEast2); - var amazonS3Adapter = new AmazonS3Adapter("prefix", "/root-path", amazonS3Client.Object, "bucket"); + var amazonS3Client = Substitute.For(); + var amazonS3Adapter = new AmazonS3Adapter("prefix", "/root-path", amazonS3Client, "bucket"); Assert.Equal("prefix", amazonS3Adapter.Prefix); Assert.Equal("/root-path", amazonS3Adapter.RootPath); @@ -25,17 +24,16 @@ public void Test_Instantiation() [Fact] public async Task Test_Get_File_Async() { - var amazonS3Client = new Mock("awsAccessKeyId", "awsSecretAccessKey", RegionEndpoint.USEast2); - var amazonS3Adapter = new AmazonS3Adapter("prefix-1", "/root-path-1", amazonS3Client.Object, "bucket-1"); + var amazonS3Client = Substitute.For(); + var amazonS3Adapter = new AmazonS3Adapter("prefix-1", "/root-path-1", amazonS3Client, "bucket-1"); - var getObjectResponse = new Mock(); + var getObjectResponse = Substitute.For(); - getObjectResponse.SetupAllProperties(); - getObjectResponse.Object.Key = "test.txt"; - getObjectResponse.Object.ContentLength = 1; - getObjectResponse.Object.LastModified = new DateTime(1970, 1, 1); + getObjectResponse.Key = "test.txt"; + getObjectResponse.ContentLength = 1; + getObjectResponse.LastModified = new DateTime(1970, 1, 1); - amazonS3Client.Setup(o => o.GetObjectAsync("bucket-1", "/root-path-1/test.txt", default)).ReturnsAsync(getObjectResponse.Object); + amazonS3Client.GetObjectAsync("bucket-1", "/root-path-1/test.txt").Returns(getObjectResponse); var fileModel = new FileModel { diff --git a/Tests/src/FileSystem.Adapters.AzureBlobStorage/AzureBlobStorageAdapterTest.cs b/Tests/src/FileSystem.Adapters.AzureBlobStorage/AzureBlobStorageAdapterTest.cs index 3fb6f69..72b76a5 100644 --- a/Tests/src/FileSystem.Adapters.AzureBlobStorage/AzureBlobStorageAdapterTest.cs +++ b/Tests/src/FileSystem.Adapters.AzureBlobStorage/AzureBlobStorageAdapterTest.cs @@ -1,5 +1,5 @@ using Azure.Storage.Blobs; -using Moq; +using NSubstitute; using SharpGrip.FileSystem.Adapters.AzureBlobStorage; using Xunit; @@ -10,8 +10,8 @@ public class AzureBlobStorageAdapterTest [Fact] public void Test_Instantiation() { - var blobContainerClient = new Mock(); - var azureBlobStorageAdapter = new AzureBlobStorageAdapter("prefix", "/root-path", blobContainerClient.Object); + var blobContainerClient = Substitute.For(); + var azureBlobStorageAdapter = new AzureBlobStorageAdapter("prefix", "/root-path", blobContainerClient); Assert.Equal("prefix", azureBlobStorageAdapter.Prefix); Assert.Equal("/root-path", azureBlobStorageAdapter.RootPath); diff --git a/Tests/src/FileSystem.Adapters.Sftp/SftpAdapterTest.cs b/Tests/src/FileSystem.Adapters.Sftp/SftpAdapterTest.cs index ed4126b..a23a60c 100644 --- a/Tests/src/FileSystem.Adapters.Sftp/SftpAdapterTest.cs +++ b/Tests/src/FileSystem.Adapters.Sftp/SftpAdapterTest.cs @@ -1,5 +1,5 @@ using System.Threading.Tasks; -using Moq; +using NSubstitute; using Renci.SshNet; using SharpGrip.FileSystem.Adapters.Sftp; using SharpGrip.FileSystem.Exceptions; @@ -12,8 +12,8 @@ public class SftpAdapterTest [Fact] public void Test_Instantiation() { - var sftpClient = new Mock("hostName", "userName", "password"); - var sftpAdapter = new SftpAdapter("prefix", "/root-path", sftpClient.Object); + var sftpClient = Substitute.For("hostName", "userName", "password"); + var sftpAdapter = new SftpAdapter("prefix", "/root-path", sftpClient); Assert.Equal("prefix", sftpAdapter.Prefix); Assert.Equal("/root-path", sftpAdapter.RootPath); @@ -22,8 +22,8 @@ public void Test_Instantiation() [Fact] public void Test_Connect() { - var sftpClient = new Mock("hostName", "userName", "password"); - var sftpAdapter = new SftpAdapter("prefix-1", "/root-path-1", sftpClient.Object); + var sftpClient = Substitute.For("hostName", "userName", "password"); + var sftpAdapter = new SftpAdapter("prefix-1", "/root-path-1", sftpClient); Assert.Throws(() => sftpAdapter.Connect()); } @@ -31,8 +31,8 @@ public void Test_Connect() [Fact] public async Task Test_Get_File_Async() { - var sftpClient = new Mock("hostName", "userName", "password"); - var sftpAdapter = new SftpAdapter("prefix-1", "/root-path-1", sftpClient.Object); + var sftpClient = Substitute.For("hostName", "userName", "password"); + var sftpAdapter = new SftpAdapter("prefix-1", "/root-path-1", sftpClient); await Assert.ThrowsAsync(async () => await sftpAdapter.GetFileAsync("prefix-1://test.txt")); }