ConfirmSteps.Net
0.1.1
See the version list below for details.
dotnet add package ConfirmSteps.Net --version 0.1.1
NuGet\Install-Package ConfirmSteps.Net -Version 0.1.1
<PackageReference Include="ConfirmSteps.Net" Version="0.1.1" />
paket add ConfirmSteps.Net --version 0.1.1
#r "nuget: ConfirmSteps.Net, 0.1.1"
// Install ConfirmSteps.Net as a Cake Addin #addin nuget:?package=ConfirmSteps.Net&version=0.1.1 // Install ConfirmSteps.Net as a Cake Tool #tool nuget:?package=ConfirmSteps.Net&version=0.1.1
ConfirmSteps.Net
A simple testing suite to confirm the sequence of steps
What is ConfirmSteps.Net
ConfirmSteps.Net is a simple library to verify the correct sequence of steps with a focus on Rest APIs.
How do I get started?
Write a sequence of steps to confirm inside a unit test with your favorite testing framework:
[Test]
public async Task GettingStartedWithConfirmStepsNet()
{
// Arrange
const string baseUrl = "{{url}}";
Scenario<HttpScenarioData> scenario =
Scenario.New<HttpScenarioData>("Getting started with ConfirmSteps.Net")
.WithGlobals(e => e
.UseConst("url", "https://jsonplaceholder.typicode.com")
.UseObject("userId", d => d.UserId)
)
.WithSteps(s => s
// GET https://jsonplaceholder.typicode.com/users/1
.HttpStep("[Step-001-User-Read]",
() => RequestBuilder.Get(baseUrl).AppendPathSegments("users", "{{userId}}"),
step => step
.VerifyJson((response, _) =>
{
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
})
.Extract(e => e
.ToVars("website", FromJsonBodyToString("$.website"))
)
)
.WaitStep(100, 200)
// POST https://jsonplaceholder.typicode.com/todos
.HttpStep("[Step-002-Todo-Add]",
() => RequestBuilder.Post(baseUrl).AppendPathSegment("todos")
.WithHeaders(h => h
.Header(HeaderNames.ContentType, MediaTypeNames.Application.Json)
)
.WithBody(
"""
{
"userId": {{userId}},
"title": "Update home page of {{website}}",
"completed": false
}
"""
),
step => step
.VerifyJson((response, _) =>
{
Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
Assert.AreEqual("Update home page of hildegard.org",
response.SelectString("$.title"));
})
.Extract(e => e
.ToData(d => d.ToDoId!, FromJsonBodyToNumber("$.id"))
)
)
)
.Build()
;
HttpScenarioData data = new()
{
UserId = 1,
};
// Act
ConfirmStepResult<HttpScenarioData> confirmResult =
await scenario.ConfirmSteps(data, CancellationToken.None);
// Assert
Assert.AreEqual(ConfirmStatus.Success, confirmResult.Status);
Assert.AreEqual(201, confirmResult.Data.ToDoId);
}
Where can I get it?
First, install NuGet. Then, install ConfirmSteps.Net from the package manager console:
PM> Install-Package ConfirmSteps.Net
Or from the .NET CLI as:
dotnet add package ConfirmSteps.Net
Do you have an issue?
If you're still running into problems, file an issue above.
License, etc.
ConfirmSteps.Net is Copyright © 2023 Grégory Célet and other contributors under the MIT license.
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 is compatible. 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. |
-
net6.0
- JsonCons.JsonPath (>= 1.1.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
-
net7.0
- JsonCons.JsonPath (>= 1.1.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
• Fixed bugs