Xcepto.Internal.Http
10.3.0
See the version list below for details.
dotnet add package Xcepto.Internal.Http --version 10.3.0
NuGet\Install-Package Xcepto.Internal.Http -Version 10.3.0
<PackageReference Include="Xcepto.Internal.Http" Version="10.3.0" />
<PackageVersion Include="Xcepto.Internal.Http" Version="10.3.0" />
<PackageReference Include="Xcepto.Internal.Http" />
paket add Xcepto.Internal.Http --version 10.3.0
#r "nuget: Xcepto.Internal.Http, 10.3.0"
#:package Xcepto.Internal.Http@10.3.0
#addin nuget:?package=Xcepto.Internal.Http&version=10.3.0
#tool nuget:?package=Xcepto.Internal.Http&version=10.3.0
Xcepto.NET
Xcepto is a BDD testing framework for distributed systems. Tests are specified declaratively here.
Getting Started
Test specification happens according to the Given-When-Then pattern.
Mental model
Test steps are not immediately executed when called! They are compiled into a state machine, where transition depends on the specified conditions.
The states are linked in a chain:
[Start] -> [First] -> [Second] -> [Third] -> [Final]
The test passes, if the Final state was reached before a timeout.
Given
Xcepto.Given introduces a specification environment based on a scenario.
XceptoTest.Given(scenario, builder =>
{
// Declare test behaviour here
}
Scenario classes specify instructions to setup and prepare the system under test.
When (Actions)
Actions often require interfacing technologies. Official adapters can be used to integrate some popular ones.
XceptoTest.Given(scenario, builder =>
{
var rest = builder.RegisterAdapter(new XceptoRestAdapter());
// When
rest.PostRequest<SomeRequest, SomeResponse>(
"localhost:3000/", new SomeRequest(),
someReponse => someResponse.value > 1000);
}
Post requests in particular also enable response validation (so they are hybrid action/expectation).
Then (Expectations)
Expectations represent transition conditions.
RabbitMQ can be used to block transition until a certain kind of message is published.
XceptoTest.Given(scenario, builder =>
{
var rabbitMq = builder.RegisterAdapter(new XceptoRabbitMqAdapter(config));
// When some Action happens
// Then expect a certain response
rabbitMq.EventCondition<ResponseMessage>(
e => e.someValue == 1234);
}
Full example
Expect that the backend message bus publishes Search(Component)SearchedForArticle
whenever the client initiates a Process with a SearchForArticleRequest.
[Test]
public async Task Test()
{
// Arrange
var config = CustomRabbitMqConfig.GetRabbitMqConfig();
var searchForArticleRequest = new SearchForArticleRequest
{
ArticleName = "Christmas Tree"
};
SearchForArticleRoute articleRoute = new SearchForArticleRoute();
var postUrl = new Uri($"http://localhost:8080/{articleRoute.Path}");
await XceptoTest.Given(new ChristmasGiftsScenario(), builder =>
{
var rest = builder.RegisterAdapter(new XceptoRestAdapter());
var rabbitMq = builder.RegisterAdapter(new XceptoRabbitMqAdapter(config));
// When
rest.PostRequest<SearchForArticleRequest, SearchForArticleResponse>(
postUrl, searchForArticleRequest, _ => true);
// Then
rabbitMq.EventCondition<SearchSearchedForArticle>(
e => e.ArticleName == searchForArticleRequest.ArticleName);
});
}
Here, ChristmasGiftsScenario starts the production environment using docker compose.
The message bus also has to be configured, GetRabbitMqConfig returns a configuration
that describes the exchanges, queues and keys and references the docker container as a host.
Adapters
Xcepto supports several technologies through adapters.
Core library:
- Xcepto
Adapters:
- Xcepto.RabbitMQ (listening for messages)
- Xcepto.REST (sending POST requests, validating POST responses)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.9)
- NUnit (>= 4.2.2)
- Xcepto (>= 10.3.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Xcepto.Internal.Http:
| Package | Downloads |
|---|---|
|
Xcepto.Rest
REST adapter for Xcepto testing library |
|
|
Xcepto.SSR
SSR adapter for Xcepto testing library |
GitHub repositories
This package is not used by any popular GitHub repositories.