Skip to content

Commit d552162

Browse files
committed
Make Http request/response formatter public
1 parent 4afaab7 commit d552162

File tree

56 files changed

+194
-112
lines changed

Some content is hidden

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

56 files changed

+194
-112
lines changed

FluentAssertions.Web.sln

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Api.v8.Tests", "test
5252
EndProject
5353
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Web.v8.Tests", "test\FluentAssertions.Web.v8.Tests\FluentAssertions.Web.v8.Tests.csproj", "{056E517C-F644-4B8A-9494-09276E6E3C6B}"
5454
EndProject
55-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Web.Types", "src\FluentAssertions.Web.Types\FluentAssertions.Web.Types.csproj", "{455E5F41-B678-4286-BB4D-FC232D08CAC0}"
55+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ited.HttpFormatter", "src\Ited.HttpFormatter\Ited.HttpFormatter.csproj", "{8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3}"
56+
EndProject
57+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ited.HttpFormatter.Tests", "test\Ited.HttpFormatter.Tests\Ited.HttpFormatter.Tests.csproj", "{6BA3687F-995A-4726-96D6-366F277384F1}"
5658
EndProject
5759
Global
5860
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -104,10 +106,14 @@ Global
104106
{056E517C-F644-4B8A-9494-09276E6E3C6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
105107
{056E517C-F644-4B8A-9494-09276E6E3C6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
106108
{056E517C-F644-4B8A-9494-09276E6E3C6B}.Release|Any CPU.Build.0 = Release|Any CPU
107-
{455E5F41-B678-4286-BB4D-FC232D08CAC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
108-
{455E5F41-B678-4286-BB4D-FC232D08CAC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
109-
{455E5F41-B678-4286-BB4D-FC232D08CAC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
110-
{455E5F41-B678-4286-BB4D-FC232D08CAC0}.Release|Any CPU.Build.0 = Release|Any CPU
109+
{8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
110+
{8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
111+
{8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
112+
{8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3}.Release|Any CPU.Build.0 = Release|Any CPU
113+
{6BA3687F-995A-4726-96D6-366F277384F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
114+
{6BA3687F-995A-4726-96D6-366F277384F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
115+
{6BA3687F-995A-4726-96D6-366F277384F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
116+
{6BA3687F-995A-4726-96D6-366F277384F1}.Release|Any CPU.Build.0 = Release|Any CPU
111117
EndGlobalSection
112118
GlobalSection(SolutionProperties) = preSolution
113119
HideSolutionNode = FALSE
@@ -125,7 +131,8 @@ Global
125131
{3872DF64-5DA9-4983-90D8-2802A0A26CFE} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C}
126132
{EBB6D06F-B87F-4BDA-8F1B-A6E88C96C2E1} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF}
127133
{056E517C-F644-4B8A-9494-09276E6E3C6B} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF}
128-
{455E5F41-B678-4286-BB4D-FC232D08CAC0} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C}
134+
{8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C}
135+
{6BA3687F-995A-4726-96D6-366F277384F1} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF}
129136
EndGlobalSection
130137
GlobalSection(ExtensibilityGlobals) = postSolution
131138
SolutionGuid = {81F41C75-2F8A-4E70-BA17-38146C4BB6E6}

src/FluentAssertions.Web.Serializers.NewtonsoftJson/FluentAssertions.Web.Serializers.NewtonsoftJson.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<PackageDescription>
@@ -11,7 +11,7 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<ProjectReference Include="..\FluentAssertions.Web.Types\FluentAssertions.Web.Types.csproj" />
14+
<ProjectReference Include="..\FluentAssertions.Web\FluentAssertions.Web.csproj" />
1515
</ItemGroup>
1616

1717
</Project>

src/FluentAssertions.Web.Serializers.NewtonsoftJson/GlobalUsings.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
global using Newtonsoft.Json;
1+
global using Ited.HttpFormatter;
2+
global using Newtonsoft.Json;
23
global using System;
34
global using System.IO;
45
global using System.Text;

src/FluentAssertions.Web.Serializers.NewtonsoftJson/NewtonsoftJsonSerializer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// ReSharper disable once CheckNamespace
2+
23
namespace FluentAssertions;
34

45
/// <summary>

src/FluentAssertions.Web.v8/FluentAssertions.Web.v8.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<ProjectReference Include="..\FluentAssertions.Web.Types\FluentAssertions.Web.Types.csproj" />
21+
<ProjectReference Include="..\Ited.HttpFormatter\Ited.HttpFormatter.csproj" />
2222
</ItemGroup>
2323

2424
<ItemGroup>

src/FluentAssertions.Web/FluentAssertions.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<ProjectReference Include="..\FluentAssertions.Web.Types\FluentAssertions.Web.Types.csproj" />
15+
<ProjectReference Include="..\Ited.HttpFormatter\Ited.HttpFormatter.csproj" />
1616
</ItemGroup>
1717

1818
</Project>

src/FluentAssertions.Web.Types/FluentAssertionsWebConfig.cs renamed to src/FluentAssertions.Web/FluentAssertionsWebConfig.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// ReSharper disable once CheckNamespace
2-
namespace FluentAssertions;
1+
namespace FluentAssertions;
32

43
/// <summary>
54
/// Holder of the global <see cref="FluentAssertionsWebConfig"/>

src/FluentAssertions.Web/GlobalUsings.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
global using FluentAssertions.Execution;
33
global using FluentAssertions.Web;
44
global using FluentAssertions.Web.Internal;
5-
global using FluentAssertions.Web.Internal.Serializers;
5+
global using Ited.HttpFormatter;
66
global using System;
77
global using System.Collections.Generic;
88
global using System.Diagnostics;
9-
global using System.IO;
109
global using System.Linq;
1110
global using System.Net;
1211
global using System.Net.Http;
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using FluentAssertions.Formatting;
2-
using System.Text;
32

43
namespace FluentAssertions.Web.Internal;
54

@@ -14,15 +13,8 @@ public void Format(object value,
1413
{
1514
var assertionsFailures = (AssertionsFailures)value;
1615

17-
var messageBuilder = new StringBuilder();
18-
messageBuilder.AppendLine();
19-
messageBuilder.AppendLine();
16+
var formatted = AssertionsFailuresFormatted.GetFormatted(assertionsFailures);
2017

21-
foreach (var failure in assertionsFailures.FailuresMessages)
22-
{
23-
messageBuilder.AppendLine($" - { failure.ReplaceFirstWithLowercase() }");
24-
}
25-
26-
formattedGraph.AddFragment(messageBuilder.ToString());
18+
formattedGraph.AddFragment(formatted);
2719
}
2820
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using FluentAssertions.Formatting;
2+
3+
internal class HttpResponseMessageFormatter : IValueFormatter
4+
{
5+
public bool CanHandle(object value) => value is HttpResponseMessage;
6+
7+
/// <inheritdoc />
8+
public void Format(object value,
9+
FormattedObjectGraph formattedGraph,
10+
FormattingContext context,
11+
FormatChild formatChild)
12+
{
13+
var response = (HttpResponseMessage)value;
14+
15+
var formatted = HttpResponseMessageFormatted.GetFormatted(response);
16+
17+
formattedGraph.AddFragment(formatted);
18+
}
19+
}

0 commit comments

Comments
 (0)