diff --git a/Directory.Packages.props b/Directory.Packages.props index 3842892..300f358 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,6 +10,7 @@ + diff --git a/FluentAssertions.Web.sln b/FluentAssertions.Web.sln index b13b697..5ada8b2 100644 --- a/FluentAssertions.Web.sln +++ b/FluentAssertions.Web.sln @@ -52,7 +52,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Api.v8.Tests", "test EndProject 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}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Web.Types", "src\FluentAssertions.Web.Types\FluentAssertions.Web.Types.csproj", "{455E5F41-B678-4286-BB4D-FC232D08CAC0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ited.HttpFormatter", "src\Ited.HttpFormatter\Ited.HttpFormatter.csproj", "{8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ited.HttpFormatter.Tests", "test\Ited.HttpFormatter.Tests\Ited.HttpFormatter.Tests.csproj", "{6BA3687F-995A-4726-96D6-366F277384F1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shouldly.Web", "src\Shouldly.Web\Shouldly.Web.csproj", "{982D2645-AF8E-44E8-9E5D-D16B740913BC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -104,10 +108,18 @@ Global {056E517C-F644-4B8A-9494-09276E6E3C6B}.Debug|Any CPU.Build.0 = Debug|Any CPU {056E517C-F644-4B8A-9494-09276E6E3C6B}.Release|Any CPU.ActiveCfg = Release|Any CPU {056E517C-F644-4B8A-9494-09276E6E3C6B}.Release|Any CPU.Build.0 = Release|Any CPU - {455E5F41-B678-4286-BB4D-FC232D08CAC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {455E5F41-B678-4286-BB4D-FC232D08CAC0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {455E5F41-B678-4286-BB4D-FC232D08CAC0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {455E5F41-B678-4286-BB4D-FC232D08CAC0}.Release|Any CPU.Build.0 = Release|Any CPU + {8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3}.Release|Any CPU.Build.0 = Release|Any CPU + {6BA3687F-995A-4726-96D6-366F277384F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6BA3687F-995A-4726-96D6-366F277384F1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6BA3687F-995A-4726-96D6-366F277384F1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6BA3687F-995A-4726-96D6-366F277384F1}.Release|Any CPU.Build.0 = Release|Any CPU + {982D2645-AF8E-44E8-9E5D-D16B740913BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {982D2645-AF8E-44E8-9E5D-D16B740913BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {982D2645-AF8E-44E8-9E5D-D16B740913BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {982D2645-AF8E-44E8-9E5D-D16B740913BC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -125,7 +137,9 @@ Global {3872DF64-5DA9-4983-90D8-2802A0A26CFE} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C} {EBB6D06F-B87F-4BDA-8F1B-A6E88C96C2E1} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF} {056E517C-F644-4B8A-9494-09276E6E3C6B} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF} - {455E5F41-B678-4286-BB4D-FC232D08CAC0} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C} + {8C66744D-AC2B-4086-AC2C-5BD04D1BC0D3} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C} + {6BA3687F-995A-4726-96D6-366F277384F1} = {BFF7517A-C9EA-458D-829E-28A10F8D61BF} + {982D2645-AF8E-44E8-9E5D-D16B740913BC} = {14FDD52D-B83A-445B-BD2F-04B3E7B8033C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {81F41C75-2F8A-4E70-BA17-38146C4BB6E6} diff --git a/src/FluentAssertions.Web.Serializers.NewtonsoftJson/FluentAssertions.Web.Serializers.NewtonsoftJson.csproj b/src/FluentAssertions.Web.Serializers.NewtonsoftJson/FluentAssertions.Web.Serializers.NewtonsoftJson.csproj index 11f4299..8fcc1bc 100644 --- a/src/FluentAssertions.Web.Serializers.NewtonsoftJson/FluentAssertions.Web.Serializers.NewtonsoftJson.csproj +++ b/src/FluentAssertions.Web.Serializers.NewtonsoftJson/FluentAssertions.Web.Serializers.NewtonsoftJson.csproj @@ -1,4 +1,4 @@ - + @@ -11,7 +11,7 @@ - + diff --git a/src/FluentAssertions.Web.Serializers.NewtonsoftJson/GlobalUsings.cs b/src/FluentAssertions.Web.Serializers.NewtonsoftJson/GlobalUsings.cs index bafb58d..ad9ee51 100644 --- a/src/FluentAssertions.Web.Serializers.NewtonsoftJson/GlobalUsings.cs +++ b/src/FluentAssertions.Web.Serializers.NewtonsoftJson/GlobalUsings.cs @@ -1,4 +1,5 @@ -global using Newtonsoft.Json; +global using Ited.HttpFormatter; +global using Newtonsoft.Json; global using System; global using System.IO; global using System.Text; diff --git a/src/FluentAssertions.Web.Serializers.NewtonsoftJson/NewtonsoftJsonSerializer.cs b/src/FluentAssertions.Web.Serializers.NewtonsoftJson/NewtonsoftJsonSerializer.cs index a21cbd0..8269196 100644 --- a/src/FluentAssertions.Web.Serializers.NewtonsoftJson/NewtonsoftJsonSerializer.cs +++ b/src/FluentAssertions.Web.Serializers.NewtonsoftJson/NewtonsoftJsonSerializer.cs @@ -1,4 +1,5 @@ // ReSharper disable once CheckNamespace + namespace FluentAssertions; /// diff --git a/src/FluentAssertions.Web.Types/GlobalUsings.cs b/src/FluentAssertions.Web.Types/GlobalUsings.cs deleted file mode 100644 index 5203d66..0000000 --- a/src/FluentAssertions.Web.Types/GlobalUsings.cs +++ /dev/null @@ -1,5 +0,0 @@ -global using FluentAssertions.Web.Internal.Serializers; -global using System; -global using System.IO; -global using System.Text.Json; -global using System.Threading.Tasks; diff --git a/src/FluentAssertions.Web.Types/Properties/AssemblyInfo.cs b/src/FluentAssertions.Web.Types/Properties/AssemblyInfo.cs deleted file mode 100644 index dcb9b49..0000000 --- a/src/FluentAssertions.Web.Types/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("FluentAssertions.Web.Tests")] -[assembly: InternalsVisibleTo("FluentAssertions.Web.v8.Tests")] -[assembly: InternalsVisibleTo("FluentAssertions.Web.FluentAssertionsWebConfig.Tests")] \ No newline at end of file diff --git a/src/FluentAssertions.Web.v8/FluentAssertions.Web.v8.csproj b/src/FluentAssertions.Web.v8/FluentAssertions.Web.v8.csproj index a866bb7..8bcb574 100644 --- a/src/FluentAssertions.Web.v8/FluentAssertions.Web.v8.csproj +++ b/src/FluentAssertions.Web.v8/FluentAssertions.Web.v8.csproj @@ -18,7 +18,7 @@ - + diff --git a/src/FluentAssertions.Web/FluentAssertions.Web.csproj b/src/FluentAssertions.Web/FluentAssertions.Web.csproj index 57766fa..fc34a68 100644 --- a/src/FluentAssertions.Web/FluentAssertions.Web.csproj +++ b/src/FluentAssertions.Web/FluentAssertions.Web.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/FluentAssertions.Web.Types/FluentAssertionsWebConfig.cs b/src/FluentAssertions.Web/FluentAssertionsWebConfig.cs similarity index 90% rename from src/FluentAssertions.Web.Types/FluentAssertionsWebConfig.cs rename to src/FluentAssertions.Web/FluentAssertionsWebConfig.cs index 4f0317f..2e0153b 100644 --- a/src/FluentAssertions.Web.Types/FluentAssertionsWebConfig.cs +++ b/src/FluentAssertions.Web/FluentAssertionsWebConfig.cs @@ -1,5 +1,4 @@ -// ReSharper disable once CheckNamespace -namespace FluentAssertions; +namespace FluentAssertions; /// /// Holder of the global diff --git a/src/FluentAssertions.Web/GlobalUsings.cs b/src/FluentAssertions.Web/GlobalUsings.cs index d6b1d98..1cabd8c 100644 --- a/src/FluentAssertions.Web/GlobalUsings.cs +++ b/src/FluentAssertions.Web/GlobalUsings.cs @@ -2,11 +2,10 @@ global using FluentAssertions.Execution; global using FluentAssertions.Web; global using FluentAssertions.Web.Internal; -global using FluentAssertions.Web.Internal.Serializers; +global using Ited.HttpFormatter; global using System; global using System.Collections.Generic; global using System.Diagnostics; -global using System.IO; global using System.Linq; global using System.Net; global using System.Net.Http; diff --git a/src/FluentAssertions.Web/Internal/AssertionsFailuresFormatter.cs b/src/FluentAssertions.Web/Internal/AssertionsFailuresFormatter.cs index e406849..76ff482 100644 --- a/src/FluentAssertions.Web/Internal/AssertionsFailuresFormatter.cs +++ b/src/FluentAssertions.Web/Internal/AssertionsFailuresFormatter.cs @@ -1,5 +1,4 @@ using FluentAssertions.Formatting; -using System.Text; namespace FluentAssertions.Web.Internal; @@ -14,15 +13,8 @@ public void Format(object value, { var assertionsFailures = (AssertionsFailures)value; - var messageBuilder = new StringBuilder(); - messageBuilder.AppendLine(); - messageBuilder.AppendLine(); + var formatted = AssertionsFailuresFormatted.GetFormatted(assertionsFailures); - foreach (var failure in assertionsFailures.FailuresMessages) - { - messageBuilder.AppendLine($" - { failure.ReplaceFirstWithLowercase() }"); - } - - formattedGraph.AddFragment(messageBuilder.ToString()); + formattedGraph.AddFragment(formatted); } } diff --git a/src/FluentAssertions.Web/Internal/HttpResponseMessageFormatter.cs b/src/FluentAssertions.Web/Internal/HttpResponseMessageFormatter.cs new file mode 100644 index 0000000..ed274e7 --- /dev/null +++ b/src/FluentAssertions.Web/Internal/HttpResponseMessageFormatter.cs @@ -0,0 +1,19 @@ +using FluentAssertions.Formatting; + +internal class HttpResponseMessageFormatter : IValueFormatter +{ + public bool CanHandle(object value) => value is HttpResponseMessage; + + /// + public void Format(object value, + FormattedObjectGraph formattedGraph, + FormattingContext context, + FormatChild formatChild) + { + var response = (HttpResponseMessage)value; + + var formatted = HttpResponseMessageFormatted.GetFormatted(response); + + formattedGraph.AddFragment(formatted); + } +} \ No newline at end of file diff --git a/src/FluentAssertions.Web/Internal/AssertionsFailures.cs b/src/Ited.HttpFormatter/AssertionsFailures.cs similarity index 70% rename from src/FluentAssertions.Web/Internal/AssertionsFailures.cs rename to src/Ited.HttpFormatter/AssertionsFailures.cs index 0525393..24576f2 100644 --- a/src/FluentAssertions.Web/Internal/AssertionsFailures.cs +++ b/src/Ited.HttpFormatter/AssertionsFailures.cs @@ -1,6 +1,6 @@ -namespace FluentAssertions.Web.Internal; +namespace Ited.HttpFormatter; -internal class AssertionsFailures +public class AssertionsFailures { public AssertionsFailures(string[] failuresMessages) { diff --git a/src/Ited.HttpFormatter/AssertionsFailuresFormatted.cs b/src/Ited.HttpFormatter/AssertionsFailuresFormatted.cs new file mode 100644 index 0000000..1a25554 --- /dev/null +++ b/src/Ited.HttpFormatter/AssertionsFailuresFormatted.cs @@ -0,0 +1,19 @@ +using System.Text; + +namespace Ited.HttpFormatter; + +public class AssertionsFailuresFormatted +{ + public static string GetFormatted(AssertionsFailures assertionsFailures) + { + var messageBuilder = new StringBuilder(); + messageBuilder.AppendLine(); + messageBuilder.AppendLine(); + + foreach (var failure in assertionsFailures.FailuresMessages) + { + messageBuilder.AppendLine($" - {failure.ReplaceFirstWithLowercase()}"); + } + return messageBuilder.ToString(); + } +} diff --git a/src/FluentAssertions.Web/Internal/ContentFormatterOptions.cs b/src/Ited.HttpFormatter/ContentFormatterOptions.cs similarity index 84% rename from src/FluentAssertions.Web/Internal/ContentFormatterOptions.cs rename to src/Ited.HttpFormatter/ContentFormatterOptions.cs index 62acc46..f20950c 100644 --- a/src/FluentAssertions.Web/Internal/ContentFormatterOptions.cs +++ b/src/Ited.HttpFormatter/ContentFormatterOptions.cs @@ -1,6 +1,6 @@ -namespace FluentAssertions.Web.Internal; +namespace Ited.HttpFormatter; -internal static class ContentFormatterOptions +public static class ContentFormatterOptions { public const int MaximumReadableBytes = 128 * 1024; // 1KB holds like 500 words public const string WarningMessageWhenDisposed = "***** Content is disposed so it cannot be read. *****"; diff --git a/src/FluentAssertions.Web.Types/DeserializationException.cs b/src/Ited.HttpFormatter/DeserializationException.cs similarity index 97% rename from src/FluentAssertions.Web.Types/DeserializationException.cs rename to src/Ited.HttpFormatter/DeserializationException.cs index 98e04b5..525bf5f 100644 --- a/src/FluentAssertions.Web.Types/DeserializationException.cs +++ b/src/Ited.HttpFormatter/DeserializationException.cs @@ -1,8 +1,7 @@ // ReSharper disable once CheckNamespace -using System; using System.Runtime.Serialization; -namespace FluentAssertions; +namespace Ited.HttpFormatter; /// /// Captures serialization exceptions. diff --git a/src/Ited.HttpFormatter/GlobalUsings.cs b/src/Ited.HttpFormatter/GlobalUsings.cs new file mode 100644 index 0000000..e98d88b --- /dev/null +++ b/src/Ited.HttpFormatter/GlobalUsings.cs @@ -0,0 +1,10 @@ +global using Ited.HttpFormatter.Internal; +global using Ited.HttpFormatter; +global using System; +global using System.Collections.Generic; +global using System.IO; +global using System.Linq; +global using System.Net; +global using System.Net.Http; +global using System.Text.Json; +global using System.Threading.Tasks; diff --git a/src/FluentAssertions.Web/Internal/Guard.cs b/src/Ited.HttpFormatter/Guard.cs similarity index 92% rename from src/FluentAssertions.Web/Internal/Guard.cs rename to src/Ited.HttpFormatter/Guard.cs index 7b19163..a45934b 100644 --- a/src/FluentAssertions.Web/Internal/Guard.cs +++ b/src/Ited.HttpFormatter/Guard.cs @@ -1,6 +1,6 @@ -namespace FluentAssertions.Web.Internal; +namespace Ited.HttpFormatter; -internal static class Guard +public static class Guard { public static void ThrowIfArgumentIsNull(T obj, string paramName) where T : class diff --git a/src/FluentAssertions.Web/Internal/HttpContentExtensions.cs b/src/Ited.HttpFormatter/HttpContentExtensions.cs similarity index 92% rename from src/FluentAssertions.Web/Internal/HttpContentExtensions.cs rename to src/Ited.HttpFormatter/HttpContentExtensions.cs index 7f4a144..e43917b 100644 --- a/src/FluentAssertions.Web/Internal/HttpContentExtensions.cs +++ b/src/Ited.HttpFormatter/HttpContentExtensions.cs @@ -1,12 +1,12 @@ using System.Text; -namespace FluentAssertions.Web.Internal; +namespace Ited.HttpFormatter; -internal static class HttpContentExtensions +public static class HttpContentExtensions { public static async Task ReadAsAsync(this HttpContent content, ISerializer serializer) { - var model = await ReadAsAsync(content, typeof(T), serializer); + var model = await content.ReadAsAsync(typeof(T), serializer); return (T?)model; } @@ -19,7 +19,7 @@ internal static class HttpContentExtensions return result; } - public static Task ReadAsAsync(this HttpContent content, T _, ISerializer serializer) + public static Task ReadAsAsync(this HttpContent content, T _, ISerializer serializer) => content.ReadAsAsync(serializer); public static bool IsDisposed(this HttpContent? content) diff --git a/src/FluentAssertions.Web/Internal/HttpResponseMessageExtensions.cs b/src/Ited.HttpFormatter/HttpResponseMessageExtensions.cs similarity index 94% rename from src/FluentAssertions.Web/Internal/HttpResponseMessageExtensions.cs rename to src/Ited.HttpFormatter/HttpResponseMessageExtensions.cs index d7f5c33..79c6237 100644 --- a/src/FluentAssertions.Web/Internal/HttpResponseMessageExtensions.cs +++ b/src/Ited.HttpFormatter/HttpResponseMessageExtensions.cs @@ -1,6 +1,6 @@ -namespace FluentAssertions.Web.Internal; +namespace Ited.HttpFormatter; -internal static class HttpResponseMessageExtensions +public static class HttpResponseMessageExtensions { public static IEnumerable GetHeaderValues(this HttpResponseMessage response, string header) { diff --git a/src/FluentAssertions.Web/HttpResponseMessageFormatter.cs b/src/Ited.HttpFormatter/HttpResponseMessageFormatted.cs similarity index 87% rename from src/FluentAssertions.Web/HttpResponseMessageFormatter.cs rename to src/Ited.HttpFormatter/HttpResponseMessageFormatted.cs index 33916f1..7755e04 100644 --- a/src/FluentAssertions.Web/HttpResponseMessageFormatter.cs +++ b/src/Ited.HttpFormatter/HttpResponseMessageFormatted.cs @@ -1,21 +1,12 @@ -using FluentAssertions.Formatting; -using FluentAssertions.Web.Internal.ContentProcessors; +using Ited.HttpFormatter.Internal.ContentProcessors; using System.Text; -namespace FluentAssertions.Web; +namespace Ited.HttpFormatter; -internal class HttpResponseMessageFormatter : IValueFormatter +public class HttpResponseMessageFormatted { - public bool CanHandle(object value) => value is HttpResponseMessage; - - /// - public void Format(object value, - FormattedObjectGraph formattedGraph, - FormattingContext context, - FormatChild formatChild) + public static string GetFormatted(HttpResponseMessage response) { - var response = (HttpResponseMessage)value; - var messageBuilder = new StringBuilder(); messageBuilder.AppendLine(); messageBuilder.AppendLine(); @@ -24,7 +15,8 @@ public void Format(object value, Func contentResolver = async () => await AppendHttpResponseMessage(messageBuilder, response); contentResolver.ExecuteInDefaultSynchronizationContext().GetAwaiter().GetResult(); - formattedGraph.AddFragment(messageBuilder.ToString()); + var formatted = messageBuilder.ToString(); + return formatted; } private static async Task AppendHttpResponseMessage(StringBuilder messageBuilder, HttpResponseMessage response) @@ -115,4 +107,4 @@ private static void AppendContentLength(StringBuilder messageBuilder, HttpConten } } } -} \ No newline at end of file +} diff --git a/src/FluentAssertions.Web.Types/ISerializer.cs b/src/Ited.HttpFormatter/ISerializer.cs similarity index 80% rename from src/FluentAssertions.Web.Types/ISerializer.cs rename to src/Ited.HttpFormatter/ISerializer.cs index 55d966e..c8e15fb 100644 --- a/src/FluentAssertions.Web.Types/ISerializer.cs +++ b/src/Ited.HttpFormatter/ISerializer.cs @@ -1,9 +1,4 @@ -// ReSharper disable once CheckNamespace -using System; -using System.IO; -using System.Threading.Tasks; - -namespace FluentAssertions; +namespace Ited.HttpFormatter; /// /// Provides an abstraction to deserialize a Stream of binary data into a C# object. diff --git a/src/FluentAssertions.Web/Internal/ContentProcessors/Appender.cs b/src/Ited.HttpFormatter/Internal/ContentProcessors/Appender.cs similarity index 94% rename from src/FluentAssertions.Web/Internal/ContentProcessors/Appender.cs rename to src/Ited.HttpFormatter/Internal/ContentProcessors/Appender.cs index 929ef45..6bf630b 100644 --- a/src/FluentAssertions.Web/Internal/ContentProcessors/Appender.cs +++ b/src/Ited.HttpFormatter/Internal/ContentProcessors/Appender.cs @@ -1,6 +1,6 @@ using System.Text; -namespace FluentAssertions.Web.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Internal.ContentProcessors; internal static class Appender { diff --git a/src/FluentAssertions.Web/Internal/ContentProcessors/BinaryProcessor.cs b/src/Ited.HttpFormatter/Internal/ContentProcessors/BinaryProcessor.cs similarity index 97% rename from src/FluentAssertions.Web/Internal/ContentProcessors/BinaryProcessor.cs rename to src/Ited.HttpFormatter/Internal/ContentProcessors/BinaryProcessor.cs index 6c27286..4f4aa92 100644 --- a/src/FluentAssertions.Web/Internal/ContentProcessors/BinaryProcessor.cs +++ b/src/Ited.HttpFormatter/Internal/ContentProcessors/BinaryProcessor.cs @@ -1,6 +1,6 @@ using System.Text; -namespace FluentAssertions.Web.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Internal.ContentProcessors; internal class BinaryProcessor : ProcessorBase { diff --git a/src/FluentAssertions.Web/Internal/ContentProcessors/FallbackProcessor.cs b/src/Ited.HttpFormatter/Internal/ContentProcessors/FallbackProcessor.cs similarity index 88% rename from src/FluentAssertions.Web/Internal/ContentProcessors/FallbackProcessor.cs rename to src/Ited.HttpFormatter/Internal/ContentProcessors/FallbackProcessor.cs index 2197bdf..83add86 100644 --- a/src/FluentAssertions.Web/Internal/ContentProcessors/FallbackProcessor.cs +++ b/src/Ited.HttpFormatter/Internal/ContentProcessors/FallbackProcessor.cs @@ -1,6 +1,6 @@ using System.Text; -namespace FluentAssertions.Web.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Internal.ContentProcessors; internal class FallbackProcessor : ProcessorBase { @@ -28,7 +28,7 @@ protected override async Task Handle(StringBuilder contentBuilder) } // we might get here some StreamContent, let's try to print it - // but let's try not to get into this issue again https://github.com/adrianiftode/FluentAssertions.Web/issues/93 + // but let's try not to get into this issue again https://github.com/adrianiftode/Ited.HttpFormatter/issues/93 var content = await _httpContent!.SafeReadAsStringAsync(); AppendContentWithinLimits(contentBuilder, content); } diff --git a/src/FluentAssertions.Web/Internal/ContentProcessors/IContentProcessor.cs b/src/Ited.HttpFormatter/Internal/ContentProcessors/IContentProcessor.cs similarity index 66% rename from src/FluentAssertions.Web/Internal/ContentProcessors/IContentProcessor.cs rename to src/Ited.HttpFormatter/Internal/ContentProcessors/IContentProcessor.cs index 53567b4..33e2862 100644 --- a/src/FluentAssertions.Web/Internal/ContentProcessors/IContentProcessor.cs +++ b/src/Ited.HttpFormatter/Internal/ContentProcessors/IContentProcessor.cs @@ -1,6 +1,6 @@ using System.Text; -namespace FluentAssertions.Web.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Internal.ContentProcessors; internal interface IContentProcessor { diff --git a/src/FluentAssertions.Web/Internal/ContentProcessors/InternalServerErrorProcessor.cs b/src/Ited.HttpFormatter/Internal/ContentProcessors/InternalServerErrorProcessor.cs similarity index 97% rename from src/FluentAssertions.Web/Internal/ContentProcessors/InternalServerErrorProcessor.cs rename to src/Ited.HttpFormatter/Internal/ContentProcessors/InternalServerErrorProcessor.cs index 1c6c813..6a6eab4 100644 --- a/src/FluentAssertions.Web/Internal/ContentProcessors/InternalServerErrorProcessor.cs +++ b/src/Ited.HttpFormatter/Internal/ContentProcessors/InternalServerErrorProcessor.cs @@ -1,6 +1,6 @@ using System.Text; -namespace FluentAssertions.Web.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Internal.ContentProcessors; internal class InternalServerErrorProcessor : ProcessorBase { diff --git a/src/FluentAssertions.Web/Internal/ContentProcessors/JsonProcessor.cs b/src/Ited.HttpFormatter/Internal/ContentProcessors/JsonProcessor.cs similarity index 97% rename from src/FluentAssertions.Web/Internal/ContentProcessors/JsonProcessor.cs rename to src/Ited.HttpFormatter/Internal/ContentProcessors/JsonProcessor.cs index aa2e83a..a6e0f08 100644 --- a/src/FluentAssertions.Web/Internal/ContentProcessors/JsonProcessor.cs +++ b/src/Ited.HttpFormatter/Internal/ContentProcessors/JsonProcessor.cs @@ -2,7 +2,7 @@ using System.Text.Encodings.Web; using System.Text.Unicode; -namespace FluentAssertions.Web.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Internal.ContentProcessors; internal class JsonProcessor : ProcessorBase { diff --git a/src/FluentAssertions.Web/Internal/ContentProcessors/MultipartProcessor.cs b/src/Ited.HttpFormatter/Internal/ContentProcessors/MultipartProcessor.cs similarity index 96% rename from src/FluentAssertions.Web/Internal/ContentProcessors/MultipartProcessor.cs rename to src/Ited.HttpFormatter/Internal/ContentProcessors/MultipartProcessor.cs index a721ba1..d00349f 100644 --- a/src/FluentAssertions.Web/Internal/ContentProcessors/MultipartProcessor.cs +++ b/src/Ited.HttpFormatter/Internal/ContentProcessors/MultipartProcessor.cs @@ -1,6 +1,6 @@ using System.Text; -namespace FluentAssertions.Web.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Internal.ContentProcessors; internal class MultipartProcessor : ProcessorBase { diff --git a/src/FluentAssertions.Web/Internal/ContentProcessors/ProcessorBase.cs b/src/Ited.HttpFormatter/Internal/ContentProcessors/ProcessorBase.cs similarity index 94% rename from src/FluentAssertions.Web/Internal/ContentProcessors/ProcessorBase.cs rename to src/Ited.HttpFormatter/Internal/ContentProcessors/ProcessorBase.cs index f67e4ac..dcfb835 100644 --- a/src/FluentAssertions.Web/Internal/ContentProcessors/ProcessorBase.cs +++ b/src/Ited.HttpFormatter/Internal/ContentProcessors/ProcessorBase.cs @@ -1,6 +1,6 @@ using System.Text; -namespace FluentAssertions.Web.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Internal.ContentProcessors; internal abstract class ProcessorBase : IContentProcessor { diff --git a/src/FluentAssertions.Web/Internal/ContentProcessors/ProcessorsRunner.cs b/src/Ited.HttpFormatter/Internal/ContentProcessors/ProcessorsRunner.cs similarity index 91% rename from src/FluentAssertions.Web/Internal/ContentProcessors/ProcessorsRunner.cs rename to src/Ited.HttpFormatter/Internal/ContentProcessors/ProcessorsRunner.cs index 125a558..1628019 100644 --- a/src/FluentAssertions.Web/Internal/ContentProcessors/ProcessorsRunner.cs +++ b/src/Ited.HttpFormatter/Internal/ContentProcessors/ProcessorsRunner.cs @@ -1,6 +1,6 @@ using System.Text; -namespace FluentAssertions.Web.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Internal.ContentProcessors; internal static class ProcessorsRunner { diff --git a/src/FluentAssertions.Web/Internal/NoSynchronizationContextScope.cs b/src/Ited.HttpFormatter/Internal/NoSynchronizationContextScope.cs similarity index 93% rename from src/FluentAssertions.Web/Internal/NoSynchronizationContextScope.cs rename to src/Ited.HttpFormatter/Internal/NoSynchronizationContextScope.cs index abcf1ab..a1cf740 100644 --- a/src/FluentAssertions.Web/Internal/NoSynchronizationContextScope.cs +++ b/src/Ited.HttpFormatter/Internal/NoSynchronizationContextScope.cs @@ -1,6 +1,6 @@ using System.Threading; -namespace FluentAssertions.Web.Internal; +namespace Ited.HttpFormatter.Internal; internal static class NoSynchronizationContextScope { diff --git a/src/FluentAssertions.Web.Types/FluentAssertions.Web.Types.csproj b/src/Ited.HttpFormatter/Ited.HttpFormatter.csproj similarity index 74% rename from src/FluentAssertions.Web.Types/FluentAssertions.Web.Types.csproj rename to src/Ited.HttpFormatter/Ited.HttpFormatter.csproj index 9eb39d8..109c61e 100644 --- a/src/FluentAssertions.Web.Types/FluentAssertions.Web.Types.csproj +++ b/src/Ited.HttpFormatter/Ited.HttpFormatter.csproj @@ -5,6 +5,8 @@ + + diff --git a/src/FluentAssertions.Web/Internal/JsonExtensions.cs b/src/Ited.HttpFormatter/JsonExtensions.cs similarity index 96% rename from src/FluentAssertions.Web/Internal/JsonExtensions.cs rename to src/Ited.HttpFormatter/JsonExtensions.cs index 27a6a05..06cef86 100644 --- a/src/FluentAssertions.Web/Internal/JsonExtensions.cs +++ b/src/Ited.HttpFormatter/JsonExtensions.cs @@ -1,6 +1,6 @@ -namespace FluentAssertions.Web.Internal; +namespace Ited.HttpFormatter; -internal static class JsonExtensions +public static class JsonExtensions { public static IEnumerable GetStringValuesOf(this JsonDocument json, string propertyName) { @@ -28,7 +28,7 @@ public static IEnumerable GetChildrenNames(this JsonDocument json, strin } public static string? GetParentKey(this JsonDocument json, string childElement) - => GetByKeyWithParent(json, childElement) + => json.GetByKeyWithParent(childElement) .Select(c => c.parent?.Name).FirstOrDefault(); public static IEnumerable GetPropertiesByName(this JsonDocument json, string propertyName) diff --git a/src/FluentAssertions.Web/Internal/ObjectExtensions.cs b/src/Ited.HttpFormatter/ObjectExtensions.cs similarity index 52% rename from src/FluentAssertions.Web/Internal/ObjectExtensions.cs rename to src/Ited.HttpFormatter/ObjectExtensions.cs index e5abd94..cf01a1e 100644 --- a/src/FluentAssertions.Web/Internal/ObjectExtensions.cs +++ b/src/Ited.HttpFormatter/ObjectExtensions.cs @@ -1,6 +1,6 @@ -namespace FluentAssertions.Web.Internal; +namespace Ited.HttpFormatter; -internal static class ObjectExtensions +public static class ObjectExtensions { public static string ToJson(this object source) => JsonSerializer.Serialize(source); } \ No newline at end of file diff --git a/src/Ited.HttpFormatter/Properties/AssemblyInfo.cs b/src/Ited.HttpFormatter/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6442470 --- /dev/null +++ b/src/Ited.HttpFormatter/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Ited.HttpFormatter.Tests")] diff --git a/src/FluentAssertions.Web.Types/Internal/Serializers/SystemTextJsonSerializer.cs b/src/Ited.HttpFormatter/Serializers/SystemTextJsonSerializer.cs similarity index 95% rename from src/FluentAssertions.Web.Types/Internal/Serializers/SystemTextJsonSerializer.cs rename to src/Ited.HttpFormatter/Serializers/SystemTextJsonSerializer.cs index 83e04d6..80a7ff1 100644 --- a/src/FluentAssertions.Web.Types/Internal/Serializers/SystemTextJsonSerializer.cs +++ b/src/Ited.HttpFormatter/Serializers/SystemTextJsonSerializer.cs @@ -2,9 +2,9 @@ using System.Reflection; using System.Text.Json.Serialization; -namespace FluentAssertions.Web.Internal.Serializers; +namespace Ited.HttpFormatter; -internal class SystemTextJsonSerializer : ISerializer +public class SystemTextJsonSerializer : ISerializer { public async Task Deserialize(Stream content, Type modelType) { diff --git a/src/FluentAssertions.Web/Internal/StringExtensions.cs b/src/Ited.HttpFormatter/StringExtensions.cs similarity index 83% rename from src/FluentAssertions.Web/Internal/StringExtensions.cs rename to src/Ited.HttpFormatter/StringExtensions.cs index 6eed275..ebde011 100644 --- a/src/FluentAssertions.Web/Internal/StringExtensions.cs +++ b/src/Ited.HttpFormatter/StringExtensions.cs @@ -1,6 +1,6 @@ -namespace FluentAssertions.Web.Internal; +namespace Ited.HttpFormatter; -internal static class StringExtensions +public static class StringExtensions { public static string ReplaceFirstWithLowercase(this string source) => !string.IsNullOrEmpty(source) ? source[0].ToString().ToLower() + source.Substring(1) diff --git a/src/FluentAssertions.Web.Types/SystemTextJsonSerializerConfig.cs b/src/Ited.HttpFormatter/SystemTextJsonSerializerConfig.cs similarity index 95% rename from src/FluentAssertions.Web.Types/SystemTextJsonSerializerConfig.cs rename to src/Ited.HttpFormatter/SystemTextJsonSerializerConfig.cs index d06b192..6623fae 100644 --- a/src/FluentAssertions.Web.Types/SystemTextJsonSerializerConfig.cs +++ b/src/Ited.HttpFormatter/SystemTextJsonSerializerConfig.cs @@ -1,7 +1,7 @@ // ReSharper disable once CheckNamespace using System.Text.Json.Serialization; -namespace FluentAssertions; +namespace Ited.HttpFormatter; /// /// Holder of the global diff --git a/src/FluentAssertions.Web/Internal/TaskExtensions.cs b/src/Ited.HttpFormatter/TaskExtensions.cs similarity index 89% rename from src/FluentAssertions.Web/Internal/TaskExtensions.cs rename to src/Ited.HttpFormatter/TaskExtensions.cs index 63bbf0d..325f962 100644 --- a/src/FluentAssertions.Web/Internal/TaskExtensions.cs +++ b/src/Ited.HttpFormatter/TaskExtensions.cs @@ -1,4 +1,4 @@ -namespace FluentAssertions.Web.Internal; +namespace Ited.HttpFormatter; /// /// Some unit test frameworks (like xUnit) have their own synchronization context @@ -6,7 +6,7 @@ /// These methods create the task in the default synchronization context /// and blocks until the task is completed. /// -internal static class TaskExtensions +public static class TaskExtensions { public static void ExecuteInDefaultSynchronizationContext(this Action action) { diff --git a/src/Shouldly.Web/GlobalUsings.cs b/src/Shouldly.Web/GlobalUsings.cs new file mode 100644 index 0000000..4267e09 --- /dev/null +++ b/src/Shouldly.Web/GlobalUsings.cs @@ -0,0 +1,10 @@ +global using Ited.HttpFormatter; +global using Shouldly; +global using System; +global using System.Collections.Generic; +global using System.Diagnostics; +global using System.Linq; +global using System.Net; +global using System.Net.Http; +global using System.Text.Json; +global using System.Threading.Tasks; diff --git a/src/Shouldly.Web/HttpResponseMessageAssertions.cs b/src/Shouldly.Web/HttpResponseMessageAssertions.cs new file mode 100644 index 0000000..b507311 --- /dev/null +++ b/src/Shouldly.Web/HttpResponseMessageAssertions.cs @@ -0,0 +1,166 @@ +using FluentAssertions; + +namespace Shouldly +{ + [ShouldlyMethods] + public static partial class HttpResponseMessageAssertions + { + #region Be2XXSuccessful + /// + /// Asserts that a HTTP response has a successful HTTP status code. + /// + /// The HTTP response was successful if was in the range 200-299. + /// + /// A formatted phrase as is supported by explaining why the assertion + /// is needed. If the phrase does not start with the word because, it is prepended automatically. + /// + /// + /// Zero or more objects to format using the placeholders in . + /// + // ReSharper disable once InconsistentNaming + public static void ShouldBe2XXSuccessful(this HttpResponseMessage response, string because = "", params object[] becauseArgs) + { + response.ShouldNotBeNull("Expected a {context:response} to assert{reason}, but found ."); + response.IsSuccessStatusCode.ShouldBeTrue("Expected {context:response} to have a successful HTTP status code, but it was {0}{reason}.{1}"); + } + #endregion + + #region NotBe2XXSuccessful + /// + /// Asserts that a HTTP response has no successful HTTP status code. + /// + /// The HTTP response was successful if was NOT in the range 200-299. + /// + /// A formatted phrase as is supported by explaining why the assertion + /// is needed. If the phrase does not start with the word because, it is prepended automatically. + /// + /// + /// Zero or more objects to format using the placeholders in . + /// + // ReSharper disable once InconsistentNaming + public static void ShouldNotBe2XXSuccessful(this HttpResponseMessage response, string because = "", params object[] becauseArgs) + { + response.ShouldNotBeNull("Expected a {context:response} to assert{reason}, but found ."); + response.IsSuccessStatusCode.ShouldNotBe(true, "Expected {context:response} to have a successful HTTP status code, but it was {0}{reason}." + HttpResponseMessageFormatted.GetFormatted(response)); + } + #endregion + + /// + /// Asserts that HTTP response content can be an equivalent representation of the expected model. + /// + /// + /// The expected model. + /// + /// + /// A reference to the configuration object that can be used + /// to influence the way the object graphs are compared. You can also provide an alternative instance of the + /// class. The global defaults are determined by the + /// + /// + /// A formatted phrase as is supported by explaining why the assertion + /// is needed. If the phrase does not start with the word because, it is prepended automatically. + /// + /// + /// Zero or more objects to format using the placeholders in . + /// + public static void ShouldBeAs(this HttpResponseMessage response, TModel? expectedModel, string because = "", params object[] becauseArgs) + { + //Guard.ThrowIfArgumentIsNull(expectedModel, nameof(expectedModel), "Cannot verify a HTTP response content match a wildcard pattern."); + + + response.ShouldNotBeNull("Expected a {context:response} to assert{reason}, but found ."); + + var expectedModelType = expectedModel?.GetType(); + + var (success, errorMessage) = TryGetSubjectModel(response, out var subjectModel, expectedModelType); + + success.ShouldBeTrue(); + try + { + subjectModel.ShouldBeEquivalentTo(expectedModel, "Expected {context:response} to have a content equivalent to a model, but it has differences:{0}{reason}. {1}" + HttpResponseMessageFormatted.GetFormatted(response)); + } + catch (Exception ex) + { + return; + } + //Execute.Assertion + // .BecauseOf(because, becauseArgs) + // .ForCondition(success) + // .FailWith("Expected {context:response} to have a content equivalent to a model of type {0}, but the JSON representation could not be parsed, as the operation failed with the following message: {2}{reason}. {1}", + // expectedModelType.ToString() ?? "unknown type", Subject, errorMessage); + + string[] failures; + + //using (var scope = new AssertionScope()) + //{ + // subjectModel.Should().BeEquivalentTo(expectedModel, options); + + // failures = scope.Discard(); + //} + + //Execute.Assertion + // .BecauseOf(because, becauseArgs) + // .ForCondition(failures.Length == 0) + // .FailWith("Expected {context:response} to have a content equivalent to a model, but it has differences:{0}{reason}. {1}", + // new AssertionsFailures(failures), + // Subject); + + //return new AndConstraint(this); + } + + private static (bool success, string? errorMessage) TryGetSubjectModel(HttpResponseMessage subject, out TModel? model) + { + var (success, errorMessage) = TryGetSubjectModel(subject, out var subjectModel, typeof(TModel)); + model = (TModel?)subjectModel; + return (success, errorMessage); + } + + private static (bool success, string? errorMessage) TryGetSubjectModel(HttpResponseMessage subject, out object? model, Type modelType) + { + Func> readModel = () => subject.Content.ReadAsAsync(modelType, ShouldlyWebConfig.Serializer); + try + { + model = readModel.ExecuteInDefaultSynchronizationContext().GetAwaiter().GetResult(); + return (true, null); + } + catch (Exception ex) when (ex is DeserializationException or NotSupportedException) + { + model = default; + var message = ex.Message; + if (ex.InnerException != null) + { + message += $": {ex.InnerException.Message}"; + } + + return (false, message); + } + } + + private static string[] CollectFailuresFromAssertion(Action assertion, TAsserted subject) + { + //using var collectionScope = new AssertionScope(); + //string[] assertionFailures; + //using (var itemScope = new AssertionScope()) + //{ + // try + // { + // assertion(subject); + // assertionFailures = itemScope.Discard(); + // } + // catch (Exception ex) + // { + // assertionFailures = new[] { $"Expected to successfully verify an assertion, but the following exception occurred: {ex}" }; + // } + + //} + + //foreach (var assertionFailure in assertionFailures) + //{ + // collectionScope.AddPreFormattedFailure($"{assertionFailure}"); + //} + + //return collectionScope.Discard(); + return new string[] { }; + } + } +} diff --git a/src/Shouldly.Web/Shouldly.Web.csproj b/src/Shouldly.Web/Shouldly.Web.csproj new file mode 100644 index 0000000..addb976 --- /dev/null +++ b/src/Shouldly.Web/Shouldly.Web.csproj @@ -0,0 +1,18 @@ + + + + + This is a Shouldy extension over the HttpResponseMessage object. It provides assertions specific to HTTP responses and outputs rich erros messages when the tests fail, so less time with debugging is spent. + + + + + + + + + + + + + diff --git a/src/Shouldly.Web/ShouldlyWebConfig.cs b/src/Shouldly.Web/ShouldlyWebConfig.cs new file mode 100644 index 0000000..7baad89 --- /dev/null +++ b/src/Shouldly.Web/ShouldlyWebConfig.cs @@ -0,0 +1,21 @@ +namespace FluentAssertions; + +/// +/// Holder of the global +/// +public static class ShouldlyWebConfig +{ + private static ISerializer? _serializer; + + static ShouldlyWebConfig() => Serializer = new SystemTextJsonSerializer(); + + /// + /// The serializer instance used to deserialize the responses into a model of a specified typed + /// + public static ISerializer Serializer + { + get => _serializer ?? throw new InvalidOperationException("Serializer cannot be null"); + + set => _serializer = value ?? throw new ArgumentNullException(nameof(value), "Serializer cannot be null."); + } +} diff --git a/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/FluentAssertions.Web.FluentAssertionsWebConfig.Tests.csproj b/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/FluentAssertions.Web.FluentAssertionsWebConfig.Tests.csproj index 3874c34..2677925 100644 --- a/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/FluentAssertions.Web.FluentAssertionsWebConfig.Tests.csproj +++ b/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/FluentAssertions.Web.FluentAssertionsWebConfig.Tests.csproj @@ -5,7 +5,6 @@ - diff --git a/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/GlobalUsings.cs b/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/GlobalUsings.cs index 94d5252..40cf973 100644 --- a/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/GlobalUsings.cs +++ b/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/GlobalUsings.cs @@ -1,2 +1,3 @@ -global using System; +global using Ited.HttpFormatter; +global using System; global using Xunit; diff --git a/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/Serializers/SystemTextJsonSerializerTests.cs b/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/Serializers/SystemTextJsonSerializerTests.cs index 29a3cba..6df6c95 100644 --- a/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/Serializers/SystemTextJsonSerializerTests.cs +++ b/test/FluentAssertions.Web.FluentAssertionsWebConfig.Tests/Serializers/SystemTextJsonSerializerTests.cs @@ -1,6 +1,4 @@ -using FluentAssertions.Web.Internal.Serializers; - -namespace FluentAssertions.Web.FluentAssertionsWebConfig.Tests.Serializers; +namespace FluentAssertions.Web.FluentAssertionsWebConfig.Tests.Serializers; [Collection("Serializers Tests")] public class SystemTextJsonSerializerTests diff --git a/test/FluentAssertions.Web.Tests/FluentAssertions.Web.Tests.csproj b/test/FluentAssertions.Web.Tests/FluentAssertions.Web.Tests.csproj index a5dc9c4..181a941 100644 --- a/test/FluentAssertions.Web.Tests/FluentAssertions.Web.Tests.csproj +++ b/test/FluentAssertions.Web.Tests/FluentAssertions.Web.Tests.csproj @@ -5,7 +5,6 @@ - diff --git a/test/FluentAssertions.Web.Tests/GlobalUsings.cs b/test/FluentAssertions.Web.Tests/GlobalUsings.cs index f38e0f4..b1e4f61 100644 --- a/test/FluentAssertions.Web.Tests/GlobalUsings.cs +++ b/test/FluentAssertions.Web.Tests/GlobalUsings.cs @@ -1,7 +1,6 @@ -global using FluentAssertions.Equivalency; +global using Ited.HttpFormatter; +global using FluentAssertions.Equivalency; global using FluentAssertions.Execution; -global using FluentAssertions.Web.Internal; -global using FluentAssertions.Web.Internal.Serializers; global using System; global using System.Collections.Generic; global using System.IO; @@ -10,7 +9,6 @@ global using System.Net.Http.Headers; global using System.Net.Http; global using System.Text; -global using System.Text.Json; global using System.Threading.Tasks; global using Xunit; global using Xunit.Sdk; diff --git a/test/FluentAssertions.Web.v8.Tests/FluentAssertions.Web.v8.Tests.csproj b/test/FluentAssertions.Web.v8.Tests/FluentAssertions.Web.v8.Tests.csproj index 7559fe8..e0acd05 100644 --- a/test/FluentAssertions.Web.v8.Tests/FluentAssertions.Web.v8.Tests.csproj +++ b/test/FluentAssertions.Web.v8.Tests/FluentAssertions.Web.v8.Tests.csproj @@ -9,7 +9,6 @@ - diff --git a/test/Ited.HttpFormatter.Tests/GlobalUsings.cs b/test/Ited.HttpFormatter.Tests/GlobalUsings.cs new file mode 100644 index 0000000..1126d62 --- /dev/null +++ b/test/Ited.HttpFormatter.Tests/GlobalUsings.cs @@ -0,0 +1,13 @@ +global using FluentAssertions; +global using Ited.HttpFormatter.Internal; +global using Ited.HttpFormatter.Internal.ContentProcessors; +global using System.Collections.Generic; +global using System.IO; +global using System.Linq; +global using System.Net; +global using System.Net.Http.Headers; +global using System.Net.Http; +global using System.Text; +global using System.Text.Json; +global using System.Threading.Tasks; +global using Xunit; \ No newline at end of file diff --git a/test/FluentAssertions.Web.Tests/Internal/ContentProcessors/FallbackProcessorTests.cs b/test/Ited.HttpFormatter.Tests/Internal/ContentProcessors/FallbackProcessorTests.cs similarity index 96% rename from test/FluentAssertions.Web.Tests/Internal/ContentProcessors/FallbackProcessorTests.cs rename to test/Ited.HttpFormatter.Tests/Internal/ContentProcessors/FallbackProcessorTests.cs index c485074..03a58ea 100644 --- a/test/FluentAssertions.Web.Tests/Internal/ContentProcessors/FallbackProcessorTests.cs +++ b/test/Ited.HttpFormatter.Tests/Internal/ContentProcessors/FallbackProcessorTests.cs @@ -1,6 +1,4 @@ -using FluentAssertions.Web.Internal.ContentProcessors; - -namespace FluentAssertions.Web.Tests.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Tests.Internal.ContentProcessors; public class FallbackProcessorTests { diff --git a/test/FluentAssertions.Web.Tests/Internal/ContentProcessors/InternalServerErrorProcessorTests.cs b/test/Ited.HttpFormatter.Tests/Internal/ContentProcessors/InternalServerErrorProcessorTests.cs similarity index 95% rename from test/FluentAssertions.Web.Tests/Internal/ContentProcessors/InternalServerErrorProcessorTests.cs rename to test/Ited.HttpFormatter.Tests/Internal/ContentProcessors/InternalServerErrorProcessorTests.cs index f82af85..de2afbb 100644 --- a/test/FluentAssertions.Web.Tests/Internal/ContentProcessors/InternalServerErrorProcessorTests.cs +++ b/test/Ited.HttpFormatter.Tests/Internal/ContentProcessors/InternalServerErrorProcessorTests.cs @@ -1,6 +1,4 @@ -using FluentAssertions.Web.Internal.ContentProcessors; - -namespace FluentAssertions.Web.Tests.Internal.ContentProcessors; +namespace Ited.HttpFormatter.Tests.Internal.ContentProcessors; public class InternalServerErrorProcessorTests { @@ -313,7 +311,7 @@ .page .length {

An unhandled exception occurred while processing the request.

Exception: Wow!
-

Sample.Api.Tests.CustomStartupConfigurationsTests+<>c.<GetException_WhenDeveloperPageIsConfigured_ShouldBeInternalServerError>b__0_2(HttpContext context, Func<Task> next) in CustomStartupConfigurationsTests.cs, line 26

+

Sample.Api.Tests.CustomStartupConfigurationsTests+<>c.<GetException_WhenDeveloperPageIsConfigured_ShouldBeInternalServerError>b__0_2(HttpContext context, Func<Task> next) in CustomStartupConfigurationsTests.cs, line 26