private static async Task CopyFileWorksAsync( CopyAsync copyAsync, string srcPrefix, CloudBlobCoreFileStorageService srcService, string destPrefix, CloudBlobCoreFileStorageService destService) { // Arrange var srcFolderName = CoreConstants.Folders.ValidationFolderName; var srcFileName = $"{srcPrefix}/src"; var srcContent = "Hello, world."; var destFolderName = CoreConstants.Folders.PackagesFolderName; var destFileName = $"{destPrefix}/dest"; await srcService.SaveFileAsync( srcFolderName, srcFileName, new MemoryStream(Encoding.ASCII.GetBytes(srcContent)), overwrite : false); // Act await copyAsync(srcService, srcFolderName, srcFileName, destService, destFolderName, destFileName); // Assert using (var destStream = await destService.GetFileAsync(destFolderName, destFileName)) using (var destReader = new StreamReader(destStream)) { var destContent = destReader.ReadToEnd(); Assert.Equal(srcContent, destContent); } }
public TheCopyFileAsyncMethod() { _srcFolderName = "validation"; _srcFileName = "4b6f16cc-7acd-45eb-ac21-33f0d927ec14/nuget.versioning.4.5.0.nupkg"; _srcETag = "\"src-etag\""; _srcUri = new Uri("https://example/nuget.versioning.4.5.0.nupkg"); _srcProperties = new BlobProperties(); _destFolderName = "packages"; _destFileName = "nuget.versioning.4.5.0.nupkg"; _destETag = "\"dest-etag\""; _destProperties = new BlobProperties(); _destCopyState = new CopyState(); SetDestCopyStatus(CopyStatus.Success); _blobClient = new Mock <ICloudBlobClient>(); _srcContainer = new Mock <ICloudBlobContainer>(); _destContainer = new Mock <ICloudBlobContainer>(); _srcBlobMock = new Mock <ISimpleCloudBlob>(); _destBlobMock = new Mock <ISimpleCloudBlob>(); _blobClient .Setup(x => x.GetContainerReference(_srcFolderName)) .Returns(() => _srcContainer.Object); _blobClient .Setup(x => x.GetContainerReference(_destFolderName)) .Returns(() => _destContainer.Object); _srcContainer .Setup(x => x.GetBlobReference(_srcFileName)) .Returns(() => _srcBlobMock.Object); _destContainer .Setup(x => x.GetBlobReference(_destFileName)) .Returns(() => _destBlobMock.Object); _srcBlobMock .Setup(x => x.Name) .Returns(() => _srcFileName); _srcBlobMock .Setup(x => x.ETag) .Returns(() => _srcETag); _srcBlobMock .Setup(x => x.Properties) .Returns(() => _srcProperties); _destBlobMock .Setup(x => x.ETag) .Returns(() => _destETag); _destBlobMock .Setup(x => x.Properties) .Returns(() => _destProperties); _destBlobMock .Setup(x => x.CopyState) .Returns(() => _destCopyState); _target = CreateService(fakeBlobClient: _blobClient); }
public CloudBlobCoreFileStorageServiceIntegrationTests(BlobStorageFixture fixture) { _fixture = fixture ?? throw new ArgumentNullException(nameof(fixture)); _testId = Guid.NewGuid().ToString(); _prefixA = $"{_fixture.PrefixA}/{_testId}"; _prefixB = $"{_fixture.PrefixB}/{_testId}"; _clientA = new CloudBlobClientWrapper(_fixture.ConnectionStringA, readAccessGeoRedundant: false); _clientB = new CloudBlobClientWrapper(_fixture.ConnectionStringB, readAccessGeoRedundant: false); _blobClientA = CloudStorageAccount.Parse(_fixture.ConnectionStringA).CreateCloudBlobClient(); _blobClientB = CloudStorageAccount.Parse(_fixture.ConnectionStringB).CreateCloudBlobClient(); _targetA = new CloudBlobCoreFileStorageService(_clientA, Mock.Of <IDiagnosticsService>()); _targetB = new CloudBlobCoreFileStorageService(_clientB, Mock.Of <IDiagnosticsService>()); }
private static async Task CopyFileWithNamesAsync( CloudBlobCoreFileStorageService srcService, string srcFolderName, string srcFileName, CloudBlobCoreFileStorageService destService, string destFolderName, string destFileName) { var destAccessCondition = AccessConditionWrapper.GenerateIfNotExistsCondition(); await destService.CopyFileAsync( srcFolderName, srcFileName, destFolderName, destFileName, destAccessCondition); }
private static async Task CopyFileWithUriAsync( CloudBlobCoreFileStorageService srcService, string srcFolderName, string srcFileName, CloudBlobCoreFileStorageService destService, string destFolderName, string destFileName) { var endOfAccess = DateTimeOffset.UtcNow.AddHours(1); var srcUri = await srcService.GetFileReadUriAsync(srcFolderName, srcFileName, endOfAccess); var destAccessCondition = AccessConditionWrapper.GenerateIfNotExistsCondition(); await destService.CopyFileAsync( srcUri, destFolderName, destFileName, destAccessCondition); }