Coder Social home page Coder Social logo

kaylumah.testing.azurite's Introduction

Kaylumah.Testing.Azurite

This package aims to provide a set of test utility classes for applications using the Azure SDK for dotnet. Specifically, it provides access to Azure Storage APIs via Azurite.

Description

Azurite emulates Azure Blob, Azure Table and Azure Queue storage APIs. It can be run via NPM or as a Docker container. Azurite has a lot of configuration options, so we cannot assume how it is running.

The package offers an AzuriteAccount class that provides access to the connection information. For example, if you started Azurite without any options, you can create an AzuriteAccount like this:

[Fact]
public void TestDefaultHttpConnectionString()
{
    AzuriteAccount account = AzuriteHelper.CreateDefaultAzuriteAccountBuilder();
    account.ConnectionString
        .Should()
        .BeEquivalentTo(
            "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;");
}

For convenience, the package offers methods to create SDK clients.

For Table Storage

[Fact(Timeout = 300_000)]
public async Task TestCanConnectToTableServiceViaConnectionString()
{
    AzuriteAccount account = AzuriteHelper.CreateDefaultAzuriteAccountBuilder();
    var tableServiceClient = account.CreateTableServiceClient(AzuriteConnectionMode.ConnectionString);
    var properties = await tableServiceClient.GetPropertiesAsync();
    properties.GetRawResponse().Status.Should().Be(200);
}

For Blob Storage

[Fact(Timeout = 300_000)]
public async Task TestCanConnectToBlobServiceViaConnectionString()
{
    AzuriteAccount account = AzuriteHelper.CreateDefaultAzuriteAccountBuilder();
    var blobServiceClient = account.CreateBlobServiceClient(AzuriteConnectionMode.ConnectionString);
    var properties = await blobServiceClient.GetPropertiesAsync();
    properties.GetRawResponse().Status.Should().Be(200);
}

For Queue Storage

[Fact(Timeout = 300_000)]
public async Task TestCanConnectToQueueServiceViaConnectionString()
{
    AzuriteAccount account = AzuriteHelper.CreateDefaultAzuriteAccountBuilder();
    var queueServiceClient = account.CreateQueueServiceClient(AzuriteConnectionMode.ConnectionString);
    var properties = await queueServiceClient.GetPropertiesAsync();
    properties.GetRawResponse().Status.Should().Be(200);
}

Features

  • Does not assume how Azurite is running
    • Configure an AzuriteAccountBuilder to create an AzuriteAccount
  • Create SDK clients from AzuriteAccount
    • Supports BlobServiceClient
    • Supports TableServiceClient
    • Supports QueueServiceClient
  • Create SDK clients using
    • ConnectionString
    • SharedKeyCredential
    • TokenCredential
    • AzureSasCredential

License

This repo is licensed under the MIT License

kaylumah.testing.azurite's People

Contributors

dependabot[bot] avatar kaylumah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.