Home

Awesome

<img src="/src/icon.png" height="30px"> Verify.Cosmos

Discussions Build status NuGet Status

Adds Verify support to verify Azure CosmosDB.

See Milestones for release notes.

NuGet package

https://nuget.org/packages/Verify.Cosmos/

Usage

<!-- snippet: enable -->

<a id='snippet-enable'></a>

[ModuleInitializer]
public static void Init() =>
    VerifyCosmos.Initialize();

<sup><a href='/src/Tests/ModuleInitializer.cs#L3-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-enable' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

ItemResponse

A ItemResponse can be verified:

<!-- snippet: ItemResponse -->

<a id='snippet-ItemResponse'></a>

var response = await container.CreateItemAsync(
    item,
    new PartitionKey(item.LastName));
await Verify(response);

<sup><a href='/src/Tests/Tests.cs#L44-L51' title='Snippet source file'>snippet source</a> | <a href='#snippet-ItemResponse' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Resulting in:

<!-- snippet: Tests.ItemResponse.verified.txt -->

<a id='snippet-Tests.ItemResponse.verified.txt'></a>

{
  RequestCharge: 7.4,
  Headers: {},
  StatusCode: Created,
  Resource: {
    Id: Guid_1,
    LastName: Andersen,
    Address: {
      State: WA,
      County: King,
      City: Seattle
    }
  }
}

<sup><a href='/src/Tests/Tests.ItemResponse.verified.txt#L1-L14' title='Snippet source file'>snippet source</a> | <a href='#snippet-Tests.ItemResponse.verified.txt' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

FeedResponse

A FeedResponse can be verified:

<!-- snippet: FeedResponse -->

<a id='snippet-FeedResponse'></a>

using var iterator = container.GetItemLinqQueryable<Family>()
    .Where(b => b.Id == item.Id)
    .ToFeedIterator();
var feedResponse = await iterator.ReadNextAsync();
await Verify(feedResponse);

<sup><a href='/src/Tests/Tests.cs#L77-L85' title='Snippet source file'>snippet source</a> | <a href='#snippet-FeedResponse' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Resulting in:

<!-- snippet: Tests.FeedResponse.verified.txt -->

<a id='snippet-Tests.FeedResponse.verified.txt'></a>

{
  RequestCharge: 2.8,
  Count: 1,
  Headers: {},
  StatusCode: OK,
  Resource: [
    {
      Id: Guid_1,
      LastName: Andersen,
      Address: {
        State: WA,
        County: King,
        City: Seattle
      }
    }
  ]
}

<sup><a href='/src/Tests/Tests.FeedResponse.verified.txt#L1-L17' title='Snippet source file'>snippet source</a> | <a href='#snippet-Tests.FeedResponse.verified.txt' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Icon

Approval designed by Mike Zuidgeest from The Noun Project.