public async Task CreateSharedAccessSignature_returns_token_created_using_DelegationKey() { var config = new CvpConfiguration() { StorageEndpoint = "https://container.blob.core.windows.net/", StorageContainerName = "container", StorageAccountName = "accountName", StorageAccountKey = "YWNjb3VudEtleQ==" }; var blobServiceClient = new Mock <BlobServiceClient>(); blobServiceClient .Setup(x => x.GetUserDelegationKeyAsync(It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>(), It.IsAny <CancellationToken>())) .ReturnsAsync(Response.FromValue(BlobsModelFactory.UserDelegationKey("", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now), null)); var service = new CvpAzureStorageService(blobServiceClient.Object, config, true); var result = await service.CreateSharedAccessSignature("myFilePath", TimeSpan.FromDays(7)); result.Should().NotBeNullOrEmpty(); result.Should().StartWith($"{config.StorageEndpoint}{config.StorageContainerName}/myFilePath?"); blobServiceClient .Verify(x => x.GetUserDelegationKeyAsync(It.IsAny <DateTimeOffset>(), It.IsAny <DateTimeOffset>(), It.IsAny <CancellationToken>()), Times.Once); }