-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use GitHub actions for the CI and build the NuGet packages. * Remove dependency to FluentAssertions library.
- Loading branch information
1 parent
91b7877
commit 15b40d0
Showing
15 changed files
with
295 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
push: | ||
branches: [ "releases/**" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup .NET 6.x | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '6.x' | ||
|
||
- name: Build | ||
run: dotnet build --property:Configuration=Debug "PosInformatique.Logging.Assertions.sln" | ||
|
||
- name: Test with the dotnet CLI | ||
run: dotnet test --property:Configuration=Debug "PosInformatique.Logging.Assertions.sln" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
VersionPrefix: | ||
type: string | ||
description: The version of the library | ||
required: true | ||
default: 1.6.0 | ||
VersionSuffix: | ||
type: string | ||
description: The version suffix of the library (for example rc.1) | ||
|
||
run-name: ${{ inputs.VersionPrefix }}-${{ inputs.VersionSuffix }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup .NET 6.x | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '6.x' | ||
|
||
- name: Build | ||
run: dotnet pack | ||
--property:Configuration=Release | ||
--property:VersionPrefix=${{ github.event.inputs.VersionPrefix }} | ||
--property:VersionSuffix=${{ github.event.inputs.VersionSuffix }} | ||
"src/Logging.Assertions/Logging.Assertions.csproj" | ||
|
||
- name: Publish the package to nuget.org | ||
run: dotnet nuget push "src/Logging.Assertions/bin/Release/*.nupkg" --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="AssertionHelper.cs" company="P.O.S Informatique"> | ||
// Copyright (c) P.O.S Informatique. All rights reserved. | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
namespace PosInformatique.Logging.Assertions | ||
{ | ||
internal static class AssertionHelper | ||
{ | ||
public static string ToString(object? @object) | ||
{ | ||
if (@object is null) | ||
{ | ||
return "null"; | ||
} | ||
|
||
return @object.ToString(); | ||
} | ||
|
||
public static void BeEquivalentTo(object actual, object expected) | ||
{ | ||
if (!Equals(actual, expected)) | ||
{ | ||
throw new LoggingAssertionFailedException($"Expected value: {ToString(expected)}{Environment.NewLine}Actual value: {ToString(actual)}"); | ||
} | ||
} | ||
|
||
public static void BeEquivalentTo(IDictionary<string, object> actual, IDictionary<string, object> expected) | ||
{ | ||
if (actual.Count != expected.Count) | ||
{ | ||
if (expected.Count > actual.Count) | ||
{ | ||
var missingKeys = new List<string>(); | ||
|
||
foreach (var expectedKey in expected.Keys) | ||
{ | ||
if (!actual.ContainsKey(expectedKey)) | ||
{ | ||
missingKeys.Add(expectedKey); | ||
} | ||
} | ||
|
||
var missingKeysList = string.Join(", ", missingKeys.Select(k => "\"" + k + "\"")); | ||
|
||
throw new LoggingAssertionFailedException($"Expected state to be a dictionary with {expected.Count} item(s), but it misses key(s) {{{missingKeysList}}}"); | ||
} | ||
else | ||
{ | ||
var additionalKeys = new List<string>(); | ||
|
||
foreach (var actualKey in actual.Keys) | ||
{ | ||
if (!expected.ContainsKey(actualKey)) | ||
{ | ||
additionalKeys.Add(actualKey); | ||
} | ||
} | ||
|
||
var additionalKeysList = string.Join(", ", additionalKeys.Select(k => "\"" + k + "\"")); | ||
|
||
throw new LoggingAssertionFailedException($"Expected state to be a dictionary with {expected.Count} item(s), but has additional key(s) {{{additionalKeysList}}}"); | ||
} | ||
} | ||
} | ||
|
||
public static void BeSameAs(Exception actual, Exception expected) | ||
{ | ||
if (actual.GetType() != expected.GetType()) | ||
{ | ||
throw new LoggingAssertionFailedException($"Expected exception to refer to {expected.GetType().FullName} with message \"{expected.Message}\", but found {actual.GetType().FullName} with message \"{actual.Message}\"."); | ||
} | ||
|
||
if (!actual.Message.Equals(expected.Message, StringComparison.InvariantCulture)) | ||
{ | ||
throw new LoggingAssertionFailedException($"Expected exception to refer to {expected.GetType().FullName} with message \"{expected.Message}\", but found {actual.GetType().FullName} with message \"{actual.Message}\"."); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.