public void Given_Null_Path_When_GetSchemaAsync_Invoked_Then_It_Should_Throw_Exception() { var instance = new BlobStorageSchemaSink(); Func <Task> func = async() => await instance.GetSchemaAsync(null).ConfigureAwait(false); func.Should().Throw <ArgumentNullException>(); }
public async Task Given_Invalid_Container_When_GetSchemaAsync_Invoked_Then_It_Should_Throw_Exception(string container, string path) { var account = CloudStorageAccount.DevelopmentStorageAccount; var blobClient = account.CreateCloudBlobClient(); await blobClient.GetContainerReference(container) .DeleteIfExistsAsync() .ConfigureAwait(false); var instance = new BlobStorageSchemaSink(blobClient) .WithContainer(container); Func <Task> func = async() => await instance.GetSchemaAsync(path).ConfigureAwait(false); func.Should().Throw <BlobContainerNotFoundException>(); }
public async Task Given_Blob_When_GetSchemaAsync_Invoked_Then_It_Should_Return_Result(string container, string path, string schema) { var account = CloudStorageAccount.DevelopmentStorageAccount; var blobClient = account.CreateCloudBlobClient(); var blobContainer = blobClient.GetContainerReference(container); await blobContainer.CreateIfNotExistsAsync().ConfigureAwait(false); var blob = blobContainer.GetBlockBlobReference(path); await blob.UploadTextAsync(schema).ConfigureAwait(false); var instance = new BlobStorageSchemaSink(blobClient) .WithContainer(container); var result = await instance.GetSchemaAsync(path).ConfigureAwait(false); result.Should().Be(schema); await blob.DeleteIfExistsAsync().ConfigureAwait(false); await blobClient.GetContainerReference(container) .DeleteIfExistsAsync() .ConfigureAwait(false); }