Skip to content

Commit

Permalink
docs: cleanup markdown files and fix getting-started (#210)
Browse files Browse the repository at this point in the history
Also cleanup build pipeline files
  • Loading branch information
vbreuss authored Jan 18, 2025
1 parent e6e61cc commit d3e369c
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 73 deletions.
4 changes: 2 additions & 2 deletions .nuke/parameters.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "build.schema.json",
"Solution": "aweXpect.sln"
"$schema": "build.schema.json",
"Solution": "aweXpect.sln"
}
8 changes: 4 additions & 4 deletions Benchmarks/aweXpect.Benchmarks/aweXpect.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="TUnit.Assertions" />
<PackageReference Include="BenchmarkDotNet"/>
<PackageReference Include="FluentAssertions"/>
<PackageReference Include="TUnit.Assertions"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Source\aweXpect\aweXpect.csproj" />
<ProjectReference Include="..\..\Source\aweXpect\aweXpect.csproj"/>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
13 changes: 10 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# Contributor guide

## Pull requests

**Pull requests are welcome!**
Please include a clear description of the changes you have made with your request; the title should follow the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) guideline.
Please include a clear description of the changes you have made with your request; the title should follow
the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) guideline.
All code should be covered by unit tests and comply with the coding guideline in this project.

### Technical expectations

As a framework for supporting unit testing, this project has a high standard for testing itself.
In order to support this, static code analysis is performed using [SonarCloud](https://sonarcloud.io/project/overview?id=aweXpect_aweXpect) with quality gate requiring to
In order to support this, static code analysis is performed
using [SonarCloud](https://sonarcloud.io/project/overview?id=aweXpect_aweXpect) with quality gate requiring to

- solve all issues reported by SonarCloud
- have a code coverage of > 90%

Additionally each push to the `main` branch checks the quality of the unit tests using [Stryker.NET](https://stryker-mutator.io/docs/stryker-net/introduction/).
Additionally each push to the `main` branch checks the quality of the unit tests
using [Stryker.NET](https://stryker-mutator.io/docs/stryker-net/introduction/).

## Versioning

This project uses [MinVer](https://github.com/adamralph/minver) for versioning.
10 changes: 5 additions & 5 deletions Docs/pages/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Simply use `.And` or `.Or` to combine multiple expectations, e.g.
```csharp
string subject = "something different"
await Expect.That(subject).Should().StartWith("some").And.EndWith("text");
await Expect.That(subject).StartsWith("some").And.EndsWith("text");
```
> ```
Expand All @@ -114,8 +114,8 @@ e.g.
MyClass subject = new(1, "some other content");
await Expect.That(subject)
.For(x => x.Status, x => x.Should().BeGreaterThan(1)).And
.For(x => x.Content, x => x.Should().Be("some content"));
.For(x => x.Status, x => x.IsGreaterThan(1)).And
.For(x => x.Content, x => x.Is("some content"));
```
> ```
Expand All @@ -137,8 +137,8 @@ Use the `Expect.ThatAll` or `Expect.ThatAny` syntax to combine arbitrary expecta
string subjectB = "XYZ";
await Expect.ThatAll(
Expect.That(subjectA).Should().Be("ABC"),
Expect.That(subjectB).Should().Be("DEF"));
Expect.That(subjectA).Is("ABC"),
Expect.That(subjectB).Is("DEF"));
```
> ```
Expand Down
7 changes: 4 additions & 3 deletions Pipeline/Build.Benchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ string CreateBenchmarkCommentBody()
MakeLineBold(sb, line);
continue;
}

sb.AppendLine(line);
}

Expand All @@ -127,15 +128,15 @@ string CreateBenchmarkCommentBody()

static void MakeLineBold(StringBuilder sb, string line)
{
var tokens = line.Split("|", StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
string[] tokens = line.Split("|", StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
sb.Append('|');
foreach (var token in tokens)
foreach (string token in tokens)
{
sb.Append(" **");
sb.Append(token);
sb.Append("** |");
}

sb.AppendLine();
}
}
20 changes: 10 additions & 10 deletions Pipeline/Build.Compile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,27 @@ partial class Build
.SetInformationalVersion(CoreVersion.InformationalVersion));
});

public record AssemblyVersion(string FileVersion, string InformationalVersion)
private static void ClearNugetPackages(string binPath)
{
public static AssemblyVersion FromGitVersion(GitVersion gitVersion)
if (Directory.Exists(binPath))
{
if (gitVersion is null)
foreach (string package in Directory.EnumerateFiles(binPath, "*nupkg", SearchOption.AllDirectories))
{
return null;
File.Delete(package);
}

return new AssemblyVersion(gitVersion.AssemblySemVer, gitVersion.InformationalVersion);
}
}

private static void ClearNugetPackages(string binPath)
public record AssemblyVersion(string FileVersion, string InformationalVersion)
{
if (Directory.Exists(binPath))
public static AssemblyVersion FromGitVersion(GitVersion gitVersion)
{
foreach (string package in Directory.EnumerateFiles(binPath, "*nupkg", SearchOption.AllDirectories))
if (gitVersion is null)
{
File.Delete(package);
return null;
}

return new AssemblyVersion(gitVersion.AssemblySemVer, gitVersion.InformationalVersion);
}
}
}
2 changes: 1 addition & 1 deletion Pipeline/Build.FrameworkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ partial class Build
Solution.Tests.Frameworks.aweXpect_Frameworks_XUnit2_Tests,
Solution.Tests.Frameworks.aweXpect_Frameworks_XUnit3_Core_Tests
];

Target TestFrameworks => _ => _
.DependsOn(VsTestFrameworks)
.DependsOn(TestingPlatformFrameworks)
Expand Down
2 changes: 1 addition & 1 deletion Pipeline/Build.UnitTest.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Linq;
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.Xunit;
using System.Linq;
using static Nuke.Common.Tools.Xunit.XunitTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;

Expand Down
7 changes: 1 addition & 6 deletions Pipeline/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,5 @@ partial class Build : NukeBuild
AbsolutePath TestResultsDirectory => RootDirectory / "TestResults";
GitHubActions GitHubActions => GitHubActions.Instance;

public static int Main() => Execute<Build>([
x => x.Pack,
x => x.ApiChecks,
x => x.Benchmarks,
x => x.CodeAnalysis,
]);
public static int Main() => Execute<Build>(x => x.Pack, x => x.ApiChecks, x => x.Benchmarks, x => x.CodeAnalysis);
}
20 changes: 10 additions & 10 deletions Pipeline/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LibGit2Sharp" />
<PackageReference Include="Nuke.Common" />
<PackageReference Include="Nuke.Components" />
<PackageReference Include="SharpCompress" />
<PackageReference Include="LibGit2Sharp"/>
<PackageReference Include="Nuke.Common"/>
<PackageReference Include="Nuke.Components"/>
<PackageReference Include="SharpCompress"/>
</ItemGroup>

<ItemGroup>
<PackageDownload Include="coverlet.console" Version="[3.1.2]" />
<PackageDownload Include="dotnet-sonarscanner" Version="[9.0.2]" />
<PackageDownload Include="dotnet-stryker" Version="[4.4.1]" />
<PackageDownload Include="GitVersion.Tool" Version="[6.0.5]" />
<PackageDownload Include="ReportGenerator" Version="[5.4.1]" />
<PackageDownload Include="xunit.runner.console" Version="[2.9.2]" />
<PackageDownload Include="coverlet.console" Version="[3.1.2]"/>
<PackageDownload Include="dotnet-sonarscanner" Version="[9.0.2]"/>
<PackageDownload Include="dotnet-stryker" Version="[4.4.1]"/>
<PackageDownload Include="GitVersion.Tool" Version="[6.0.5]"/>
<PackageDownload Include="ReportGenerator" Version="[5.4.1]"/>
<PackageDownload Include="xunit.runner.console" Version="[2.9.2]"/>
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions Pipeline/BuildExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Nuke.Common.CI.GitHubActions;
using System;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.Tools.SonarScanner;
using Serilog;
using System;

namespace Build;

Expand Down
15 changes: 11 additions & 4 deletions Pipeline/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
using Nuke.Common.Tooling;
using System.ComponentModel;
using Nuke.Common.Tooling;

namespace Build;

[TypeConverter(typeof(TypeConverter<Configuration>))]
public class Configuration : Enumeration
{
public static Configuration Debug = new Configuration { Value = nameof(Debug) };
public static Configuration Release = new Configuration { Value = nameof(Release) };
public static Configuration Debug = new()
{
Value = nameof(Debug)
};

public static Configuration Release = new()
{
Value = nameof(Release)
};

public static implicit operator string(Configuration configuration)
{
return configuration.Value;
}
}
}
6 changes: 3 additions & 3 deletions Pipeline/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- This file prevents unintended imports of unrelated MSBuild files -->
<!-- Uncomment to include parent Directory.Build.props file -->
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />-->
<!-- This file prevents unintended imports of unrelated MSBuild files -->
<!-- Uncomment to include parent Directory.Build.props file -->
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />-->

</Project>
6 changes: 3 additions & 3 deletions Pipeline/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- This file prevents unintended imports of unrelated MSBuild files -->
<!-- Uncomment to include parent Directory.Build.targets file -->
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />-->
<!-- This file prevents unintended imports of unrelated MSBuild files -->
<!-- Uncomment to include parent Directory.Build.targets file -->
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />-->

</Project>
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# aweXpect
[![Nuget](https://img.shields.io/nuget/v/aweXpect)](https://www.nuget.org/packages/aweXpect)
[![Build](https://github.com/aweXpect/aweXpect/actions/workflows/build.yml/badge.svg)](https://github.com/aweXpect/aweXpect/actions/workflows/build.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=aweXpect_aweXpect&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=aweXpect_aweXpect)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=aweXpect_aweXpect&metric=coverage)](https://sonarcloud.io/summary/new_code?id=aweXpect_aweXpect)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FaweXpect%2FaweXpect%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/aweXpect/aweXpect/main)

Assert unit tests in natural language using awesome expectations.
[![Nuget](https://img.shields.io/nuget/v/aweXpect)](https://www.nuget.org/packages/aweXpect)
[![Build](https://github.com/aweXpect/aweXpect/actions/workflows/build.yml/badge.svg)](https://github.com/aweXpect/aweXpect/actions/workflows/build.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=aweXpect_aweXpect&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=aweXpect_aweXpect)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=aweXpect_aweXpect&metric=coverage)](https://sonarcloud.io/summary/new_code?id=aweXpect_aweXpect)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FaweXpect%2FaweXpect%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/aweXpect/aweXpect/main)

Assert unit tests in natural language using awesome expectations.

## Getting started

Expand All @@ -20,30 +20,40 @@ Assert unit tests in natural language using awesome expectations.
using aweXpect;
```
This brings the static `Expect` class and lots of extension methods into scope.


3. See the [documentation](https://awexpect.github.io/aweXpect/docs/getting-started#write-your-first-expectation) for usage scenarios.

3. See the [documentation](https://awexpect.github.io/aweXpect/docs/getting-started#write-your-first-expectation) for
usage scenarios.

## Features

### Async everything

By using async assertions per default, we have a consistent API and other perks:

- Complete async support, e.g. `IAsyncEnumerable` `HttpResponseMessage` or similar async types
- No need to distinguish between `action.Should().Throw()` and `await asyncAction.Should().ThrowAsync()`
- The evaluation is only triggered after the complete fluent chain is loaded, which has some nice benefits:
- `Because` can be registered once as a general method that can be applied at the end of the expectation instead of cluttering all methods with the `because` and `becauseArgs` parameters
- `WithCancellation` can also be registered at the end an applies a `CancellationToken` to all async methods which allows cancellation of `IAsyncEnumerable` evaluations
- Expectations can be combined directly (via `Expect.ThatAll`) instead of relying on global state (e.g. [assertion scopes](https://fluentassertions.com/introduction#assertion-scopes))
- `Because` can be registered once as a general method that can be applied at the end of the expectation instead of
cluttering all methods with the `because` and `becauseArgs` parameters
- `WithCancellation` can also be registered at the end an applies a `CancellationToken` to all async methods which
allows cancellation of `IAsyncEnumerable` evaluations
- Expectations can be combined directly (via `Expect.ThatAll`) instead of relying on global state (
e.g. [assertion scopes](https://fluentassertions.com/introduction#assertion-scopes))

### Extensible

We added lots of extensibility points to allow you to build custom extensions.
Similar to [fluentassertions](https://fluentassertions.com/extensibility/) extensibility is achieved via extension methods on `.Should()`:
Similar to [fluentassertions](https://fluentassertions.com/extensibility/) extensibility is achieved via extension
methods on `.Should()`:

- for new types
write a new `.Should()` extension method on `IExpectSubject<TType>`
- for existing types
writing an extension method on `IThat<TType>`

### Performant

A focus on performance allows you to execute your tests as fast as possible.
Special care is taken for the happy case (succeeding tests) to be as performant as possible. See the [benchmarks](https://awexpect.github.io/aweXpect/benchmarks) for more details.
Special care is taken for the happy case (succeeding tests) to be as performant as possible. See
the [benchmarks](https://awexpect.github.io/aweXpect/benchmarks) for more details.
4 changes: 2 additions & 2 deletions nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<clear/>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json"/>
</packageSources>
</configuration>

0 comments on commit d3e369c

Please sign in to comment.