Skip to content

Commit 1265902

Browse files
authored
Merge pull request #144 from msmolka/master
Added support for AwesomeAssertions fork
2 parents 44ed5d4 + f98903c commit 1265902

File tree

90 files changed

+802
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+802
-77
lines changed

Directory.Packages.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@
1919
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.1" />
2020
</ItemGroup>
2121

22+
<ItemGroup>
23+
<PackageVersion Include="AwesomeAssertions" Version="9.0.0" />
24+
<PackageVersion Include="AwesomeAssertions.Analyzers" Version="9.0.0" />
25+
</ItemGroup>
26+
2227
</Project>

FluentAssertions.Web.sln

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Web.v8.Tes
5454
EndProject
5555
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Web.Types", "src\FluentAssertions.Web.Types\FluentAssertions.Web.Types.csproj", "{455E5F41-B678-4286-BB4D-FC232D08CAC0}"
5656
EndProject
57+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AwesomeAssertions.Web", "src\AwesomeAssertions.Web\AwesomeAssertions.Web.csproj", "{54EF3A12-DB43-48C4-A64C-97D2B62E3C2E}"
58+
EndProject
59+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AwesomeAssertions.Web.Types", "src\AwesomeAssertions.Web.Types\AwesomeAssertions.Web.Types.csproj", "{418ADD1B-EA19-4EAE-95DE-5ED327BC4E9E}"
60+
EndProject
61+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AwesomeAssertions.Web.Serializers.NewtonsoftJson", "src\AwesomeAssertions.Web.Serializers.NewtonsoftJson\AwesomeAssertions.Web.Serializers.NewtonsoftJson.csproj", "{79495BD6-C628-42E9-8147-990B8112F377}"
62+
EndProject
63+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AwesomeAssertions.Web.Tests", "test\AwesomeAssertions.Web.Tests\AwesomeAssertions.Web.Tests.csproj", "{BBBB8E66-221B-4D89-A942-E63BC7C64C94}"
64+
EndProject
65+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AwesomeAssertions.Web.Serializers.NewtonsoftJson.Tests", "test\AwesomeAssertions.Web.Serializers.NewtonsoftJson.Tests\AwesomeAssertions.Web.Serializers.NewtonsoftJson.Tests.csproj", "{1455C2AB-9EE2-4C4B-96AC-B030EB06928C}"
66+
EndProject
67+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AwesomeAssertions.Web.AwesomeAssertionsWebConfig.Tests", "test\AwesomeAssertions.Web.AwesomeAssertionsWebConfig.Tests\AwesomeAssertions.Web.AwesomeAssertionsWebConfig.Tests.csproj", "{E2EC106A-42E7-448F-85F5-85FB07BA2AC1}"
68+
EndProject
69+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Api.AwesomeAssertions.Tests", "test\Sample.Api.AwesomeAssertions.Tests\Sample.Api.AwesomeAssertions.Tests.csproj", "{2D38D734-43BF-423C-9CED-8484B5141E85}"
70+
EndProject
5771
Global
5872
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5973
Debug|Any CPU = Debug|Any CPU
@@ -108,6 +122,34 @@ Global
108122
{455E5F41-B678-4286-BB4D-FC232D08CAC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
109123
{455E5F41-B678-4286-BB4D-FC232D08CAC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
110124
{455E5F41-B678-4286-BB4D-FC232D08CAC0}.Release|Any CPU.Build.0 = Release|Any CPU
125+
{54EF3A12-DB43-48C4-A64C-97D2B62E3C2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
126+
{54EF3A12-DB43-48C4-A64C-97D2B62E3C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
127+
{54EF3A12-DB43-48C4-A64C-97D2B62E3C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
128+
{54EF3A12-DB43-48C4-A64C-97D2B62E3C2E}.Release|Any CPU.Build.0 = Release|Any CPU
129+
{418ADD1B-EA19-4EAE-95DE-5ED327BC4E9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
130+
{418ADD1B-EA19-4EAE-95DE-5ED327BC4E9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
131+
{418ADD1B-EA19-4EAE-95DE-5ED327BC4E9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
132+
{418ADD1B-EA19-4EAE-95DE-5ED327BC4E9E}.Release|Any CPU.Build.0 = Release|Any CPU
133+
{79495BD6-C628-42E9-8147-990B8112F377}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
134+
{79495BD6-C628-42E9-8147-990B8112F377}.Debug|Any CPU.Build.0 = Debug|Any CPU
135+
{79495BD6-C628-42E9-8147-990B8112F377}.Release|Any CPU.ActiveCfg = Release|Any CPU
136+
{79495BD6-C628-42E9-8147-990B8112F377}.Release|Any CPU.Build.0 = Release|Any CPU
137+
{BBBB8E66-221B-4D89-A942-E63BC7C64C94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
138+
{BBBB8E66-221B-4D89-A942-E63BC7C64C94}.Debug|Any CPU.Build.0 = Debug|Any CPU
139+
{BBBB8E66-221B-4D89-A942-E63BC7C64C94}.Release|Any CPU.ActiveCfg = Release|Any CPU
140+
{BBBB8E66-221B-4D89-A942-E63BC7C64C94}.Release|Any CPU.Build.0 = Release|Any CPU
141+
{1455C2AB-9EE2-4C4B-96AC-B030EB06928C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
142+
{1455C2AB-9EE2-4C4B-96AC-B030EB06928C}.Debug|Any CPU.Build.0 = Debug|Any CPU
143+
{1455C2AB-9EE2-4C4B-96AC-B030EB06928C}.Release|Any CPU.ActiveCfg = Release|Any CPU
144+
{1455C2AB-9EE2-4C4B-96AC-B030EB06928C}.Release|Any CPU.Build.0 = Release|Any CPU
145+
{E2EC106A-42E7-448F-85F5-85FB07BA2AC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
146+
{E2EC106A-42E7-448F-85F5-85FB07BA2AC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
147+
{E2EC106A-42E7-448F-85F5-85FB07BA2AC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
148+
{E2EC106A-42E7-448F-85F5-85FB07BA2AC1}.Release|Any CPU.Build.0 = Release|Any CPU
149+
{2D38D734-43BF-423C-9CED-8484B5141E85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
150+
{2D38D734-43BF-423C-9CED-8484B5141E85}.Debug|Any CPU.Build.0 = Debug|Any CPU
151+
{2D38D734-43BF-423C-9CED-8484B5141E85}.Release|Any CPU.ActiveCfg = Release|Any CPU
152+
{2D38D734-43BF-423C-9CED-8484B5141E85}.Release|Any CPU.Build.0 = Release|Any CPU
111153
EndGlobalSection
112154
GlobalSection(SolutionProperties) = preSolution
113155
HideSolutionNode = FALSE
@@ -126,6 +168,13 @@ Global
126168
{EBB6D06F-B87F-4BDA-8F1B-A6E88C96C2E1} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF}
127169
{056E517C-F644-4B8A-9494-09276E6E3C6B} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF}
128170
{455E5F41-B678-4286-BB4D-FC232D08CAC0} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C}
171+
{54EF3A12-DB43-48C4-A64C-97D2B62E3C2E} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C}
172+
{418ADD1B-EA19-4EAE-95DE-5ED327BC4E9E} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C}
173+
{79495BD6-C628-42E9-8147-990B8112F377} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C}
174+
{BBBB8E66-221B-4D89-A942-E63BC7C64C94} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF}
175+
{1455C2AB-9EE2-4C4B-96AC-B030EB06928C} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF}
176+
{E2EC106A-42E7-448F-85F5-85FB07BA2AC1} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF}
177+
{2D38D734-43BF-423C-9CED-8484B5141E85} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF}
129178
EndGlobalSection
130179
GlobalSection(ExtensibilityGlobals) = postSolution
131180
SolutionGuid = {81F41C75-2F8A-4E70-BA17-38146C4BB6E6}

readme.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## FluentAssertions.Web
2-
This is a [*FluentAssertions*](https://fluentassertions.com/) extension over the *HttpResponseMessage* object.
2+
This is a [*FluentAssertions*](https://fluentassertions.com/) and [*AwesomeAssertions*](https://awesomeassertions.org//) extension over the *HttpResponseMessage* object.
33

4-
It provides assertions specific to HTTP responses and outputs rich erros messages when the tests fail, so less time with debugging is spent.
4+
It provides assertions specific to HTTP responses and outputs rich errors messages when the tests fail, so less time with debugging is spent.
55

66
```csharp
77
[Fact]
@@ -33,7 +33,7 @@ Thus this library solves two problems:
3333

3434
##### Focus on the Assert part and not on the HttpClient related APIs, neither on the response deserialization
3535

36-
Once the response is ready you'll want to assert it. With first level properties like `StatusCode` is somehow easy, especially with FluentAssertions, but often we need more, like to deserialize the content into an object of a certain type and then to Assert it. Or to simply assert something about the response content itself. Soon duplication code occurs and the urge to reduce it is just the next logical step.
36+
Once the response is ready you'll want to assert it. With first level properties like `StatusCode` is somehow easy, especially with FluentAssertions/AwesomeAssertions, but often we need more, like to deserialize the content into an object of a certain type and then to Assert it. Or to simply assert something about the response content itself. Soon duplication code occurs and the urge to reduce it is just the next logical step.
3737

3838
##### Debugging failed tests interrupts the programmer's flow state
3939
When a test is failing, the following actions are taken most of the time:
@@ -65,6 +65,12 @@ If you are using FluentAssertions >= 8.0.0
6565
dotnet add package FluentAssertions.Web.v8
6666
```
6767

68+
If you are using AwesomeAssertions >= 8.0.0
69+
70+
```
71+
dotnet add package AwesomeAssertions.Web
72+
```
73+
6874
### FluentAssertions.Web Examples
6975

7076
- Asserting that the response content of a HTTP POST request is equivalent to a certain object
@@ -232,7 +238,8 @@ The change must be done before the test is run and this depends on the testing f
232238

233239
#### Newtonsoft.Json
234240

235-
The serializer itself is replaceable, so you can implement your own, by implementing the `ISerialize` interface. The serializer is shipped via the **FluentAssertions.Web.Serializers.NewtonsoftJson** package.
241+
The serializer itself is replaceable, so you can implement your own, by implementing the `ISerialize` interface.
242+
The serializer is shipped via the **FluentAssertions.Web.Serializers.NewtonsoftJson** and **AwesomeAssertions.Web.Serializers.NewtonsoftJson** package.
236243

237244
[![NuGet](https://img.shields.io/nuget/v/FluentAssertions.Web.Serializers.NewtonsoftJson.svg)](https://www.nuget.org/packages/FluentAssertions.Web.Serializers.NewtonsoftJson)
238245

@@ -242,6 +249,12 @@ To set the default serializer to **Newtonsoft.Json** one, use the following conf
242249
```csharp
243250
FluentAssertionsWebConfig.Serializer = new NewtonsoftJsonSerializer();
244251

252+
```
253+
or
254+
255+
```csharp
256+
AwesomeAssertionsWebConfig.Serializer = new NewtonsoftJsonSerializer();
257+
245258
```
246259

247260
The related `Newtonsoft.Json.JsonSerializerSetttings` used to configure the Newtonsoft.Json serializer is accesible via the `NewtonsoftJsonSerializerConfig.Options` static field. So if you want to add a custom converter, then the related setting is changed like this:
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<PackageDescription>
5+
NewtonsoftJson based serializer for AwesomeAssertions.Web
6+
</PackageDescription>
7+
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<DefineConstants>$(DefineConstants);AAV</DefineConstants>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Newtonsoft.Json" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\AwesomeAssertions.Web.Types\AwesomeAssertions.Web.Types.csproj" PrivateAssets="all" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<Compile Include="..\FluentAssertions.Web.Serializers.NewtonsoftJson\**\*.*" Exclude="**\bin\**;**\obj\**;**\Properties\**;**\*.csproj">
23+
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
24+
<PackagePath>$(ContentTargetFolders)\src\%RecursiveDir%</PackagePath>
25+
</Compile>
26+
</ItemGroup>
27+
28+
<PropertyGroup>
29+
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
30+
</PropertyGroup>
31+
32+
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="BuildOnlySettings;ResolveReferences">
33+
<ItemGroup>
34+
<!-- Filter out unnecessary files -->
35+
<_ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('PrivateAssets', 'all'))"/>
36+
</ItemGroup>
37+
38+
<!-- Print batches for debug purposes -->
39+
<Message Text="Batch for .nupkg: ReferenceCopyLocalPaths = @(_ReferenceCopyLocalPaths), ReferenceCopyLocalPaths.DestinationSubDirectory = %(_ReferenceCopyLocalPaths.DestinationSubDirectory) Filename = %(_ReferenceCopyLocalPaths.Filename) Extension = %(_ReferenceCopyLocalPaths.Extension)" Importance="High" Condition="'@(_ReferenceCopyLocalPaths)' != ''" />
40+
41+
<ItemGroup>
42+
<!-- Add file to package with consideration of sub folder. If empty, the root folder is chosen. -->
43+
<BuildOutputInPackage Include="@(_ReferenceCopyLocalPaths)" TargetPath="%(_ReferenceCopyLocalPaths.DestinationSubDirectory)"/>
44+
</ItemGroup>
45+
</Target>
46+
47+
48+
49+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<IsPackable>false</IsPackable>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="System.Text.Json" />
9+
</ItemGroup>
10+
11+
<PropertyGroup>
12+
<DefineConstants>$(DefineConstants);AAV</DefineConstants>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<Compile Include="..\FluentAssertions.Web.Types\**\*.*" Exclude="**\bin\**;**\obj\**;**\Properties\**;**\*.csproj;**\GlobalUsings.cs">
17+
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
18+
<PackagePath>$(ContentTargetFolders)\src\%RecursiveDir%</PackagePath>
19+
</Compile>
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
global using AwesomeAssertions.Web.Internal.Serializers;
2+
global using System;
3+
global using System.IO;
4+
global using System.Text.Json;
5+
global using System.Threading.Tasks;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using System.Runtime.CompilerServices;
2+
3+
[assembly: InternalsVisibleTo("AwesomeAssertions.Web.Tests")]
4+
[assembly: InternalsVisibleTo("AwesomeAssertions.Web.AwesomeAssertionsWebConfig.Tests")]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<PackageDescription>
5+
This is a AwesomeAssertions extension over the HttpResponseMessage object.
6+
It provides specific assertions and outputs rich erros messages that include the HTTP Request and Response.
7+
</PackageDescription>
8+
<PackageReadmeFile>readme.md</PackageReadmeFile>
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<DefineConstants>$(DefineConstants);FAV8;AAV</DefineConstants>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="AwesomeAssertions"/>
17+
<PackageReference Include="System.Text.Json" />
18+
<PackageReference Include="Microsoft.AspNet.WebApi.Client" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<ProjectReference Include="..\AwesomeAssertions.Web.Types\AwesomeAssertions.Web.Types.csproj" PrivateAssets="all"/>
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<None Include="../../readme.md" Pack="true" PackagePath="\" />
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<Compile Include="..\FluentAssertions.Web\**\*.*" Exclude="**\bin\**;**\obj\**;**\Properties\**;**\*.csproj;**\GlobalUsings.cs">
31+
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
32+
<PackagePath>$(ContentTargetFolders)\src\%RecursiveDir%</PackagePath>
33+
</Compile>
34+
</ItemGroup>
35+
36+
<PropertyGroup>
37+
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
38+
</PropertyGroup>
39+
40+
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="BuildOnlySettings;ResolveReferences">
41+
<ItemGroup>
42+
<!-- Filter out unnecessary files -->
43+
<_ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')-&gt;WithMetadataValue('PrivateAssets', 'all'))" />
44+
</ItemGroup>
45+
46+
<!-- Print batches for debug purposes -->
47+
<Message Text="Batch for .nupkg: ReferenceCopyLocalPaths = @(_ReferenceCopyLocalPaths), ReferenceCopyLocalPaths.DestinationSubDirectory = %(_ReferenceCopyLocalPaths.DestinationSubDirectory) Filename = %(_ReferenceCopyLocalPaths.Filename) Extension = %(_ReferenceCopyLocalPaths.Extension)" Importance="High" Condition="'@(_ReferenceCopyLocalPaths)' != ''" />
48+
49+
<ItemGroup>
50+
<!-- Add file to package with consideration of sub folder. If empty, the root folder is chosen. -->
51+
<BuildOutputInPackage Include="@(_ReferenceCopyLocalPaths)" TargetPath="%(_ReferenceCopyLocalPaths.DestinationSubDirectory)" />
52+
</ItemGroup>
53+
</Target>
54+
55+
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
global using AwesomeAssertions.Equivalency;
2+
global using AwesomeAssertions.Execution;
3+
global using AwesomeAssertions.Web;
4+
global using AwesomeAssertions.Web.Internal;
5+
global using System;
6+
global using System.Collections.Generic;
7+
global using System.Diagnostics;
8+
global using System.IO;
9+
global using System.Linq;
10+
global using System.Net;
11+
global using System.Net.Http;
12+
global using System.Text.Json;
13+
global using System.Threading.Tasks;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using System.Runtime.CompilerServices;
2+
3+
[assembly: InternalsVisibleTo("AwesomeAssertions.Web.Tests")]

0 commit comments

Comments
 (0)