Skip to content

Commit fdaef2e

Browse files
committed
update readme
1 parent 07ca595 commit fdaef2e

1 file changed

Lines changed: 73 additions & 6 deletions

File tree

README.md

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1-
# Ephemerally
1+
# Ephemerally
2+
3+
![NuGet Downloads](https://img.shields.io/nuget/dt/Ephemerally)
4+
![NuGet Version](https://img.shields.io/nuget/vpre/Ephemerally)
5+
6+
### Packages available on [nuget.org](https://www.nuget.org/packages?q=Ephemerally)
7+
8+
### Full documentation available in [the wiki](../../wiki)
29

310
## Create and automatically cleanup temporary external resources
411

5-
Infinitely extensible by design. Just install the packages for the types of resources you'd like to exist ephemerally (or create your own!).
12+
#### Extensible by design. Just install the appropriate package and start using resources ephemerally.
13+
14+
## Why use this instead of `testcontainers`?
15+
16+
Creating and tearing down entire containers per-test can be time-intensive and slow things down considerably. The best use cases will combine both approaches, using `testcontainers` to provide the infrastructure for the ephemeral resources created by `Ephemerally`, for example using `testcontainers` to provide a Redis instance for the `PooledEphemeralRedisMultiplexerFixture`.
17+
18+
There are also use cases where it is not possible to use temporary containers with something like `testcontainers`, for example when:
19+
- there is no containerized version of a resource
20+
- policy forbids it
21+
- technical challenges make it impractical
22+
- there is a specific case like performance testing, where you want or need an actual, full-scale resource
23+
24+
## Integration
25+
Basic integration points are provided in the main `Ephemerally` namespace, typically as extension methods.
626

7-
## The Convention
8-
All primary integration points are provided in the main `Ephemerally` namespace, typically as extension methods.
27+
Test fixtures will be under their respective package names (e.g. `Ephemerally.Azure.Cosmos.Xunit`).
928

10-
## Example Usage
29+
## Create Resources Ephemerally
1130
To create a temporary Cosmos database and container for your persistence unit tests:
1231
1. Install the relevant package:
1332
```
@@ -43,13 +62,61 @@ public async Task Test_should_pass()
4362
}
4463
```
4564

65+
## Test Fixtures
66+
To utilize the premade fixtures (currently only available for xUnit):
67+
1. Install the appropriate package:
68+
```
69+
dotnet add package Ephemerally.Azure.Cosmos.Xunit
70+
```
71+
2. Import the namespace
72+
```csharp
73+
using Ephemerally.Azure.Cosmos.Xunit;
74+
```
75+
3. Add a fixture to your test class
76+
```csharp
77+
using Ephemerally.Azure.Cosmos.Xunit;
78+
using Xunit;
79+
80+
public class DatabaseFixtureUsageExampleTests(EphemeralCosmosDatabaseFixture fixture)
81+
: IClassFixture<EphemeralCosmosDatabaseFixture>
82+
{
83+
// TODO: Tests go here
84+
}
85+
```
86+
4. Use the fixture
87+
```csharp
88+
using Ephemerally;
89+
using Ephemerally.Azure.Cosmos.Xunit;
90+
using Xunit;
91+
92+
public class DatabaseFixtureUsageExampleTests(EphemeralCosmosDatabaseFixture fixture)
93+
: IClassFixture<EphemeralCosmosDatabaseFixture>
94+
{
95+
[Fact]
96+
public async Task TestUsingDatabase()
97+
{
98+
// Ephemeral databases go well with ephemeral containers to keep tests isolated
99+
await using var container = await fixture.Database.CreateEphemeralContainerAsync();
100+
}
101+
}
102+
```
103+
46104
## Available Packages
47105

48106
### `Ephemerally`
49-
The core library with the main types. This will be included automatically as a dependency.
107+
Base package with shared types. This will be included automatically as a transitive dependency.
50108

51109
### `Ephemerally.Azure`
52110
Placeholder for now to hold general Azure dependencies.
53111

54112
### `Ephemerally.Azure.Cosmos`
55113
Contains types and extension methods for creating and using ephemeral Cosmos DB resources.
114+
115+
### `Ephemerally.Azure.Cosmos.Xunit`
116+
xUnit fixtures for simplifying test integration with `Ephemerally.Azure.Cosmos`
117+
118+
### `Ephemerally.Redis`
119+
Classes and methods for creating and managing the lifecycle of ephemeral Redis resources
120+
121+
### `Ephemerally.Redis.Xunit`
122+
xUnit fixtures for simplifying test integration with `Ephemerally.Redis`

0 commit comments

Comments
 (0)