Skip to content

Commit

Permalink
chore: move enum to own file
Browse files Browse the repository at this point in the history
  • Loading branch information
skwasjer committed Sep 29, 2024
1 parent b458e02 commit 76ac4e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/MockHttp/Http/HttpHeaderEqualityComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@

namespace MockHttp.Http;

internal enum HttpHeaderMatchType
{
/// <summary>
/// Header and value(s) match exactly.
/// </summary>
Exact,
/// <summary>
/// Header name matches, values are ignored.
/// </summary>
HeaderNameOnly,
/// <summary>
/// Header name matches and all values of left comparand must be in right.
/// </summary>
HeaderNameAndPartialValues
}

internal sealed class HttpHeaderEqualityComparer : IEqualityComparer<KeyValuePair<string, IEnumerable<string>>>
{
private readonly HttpHeaderMatchType? _matchType;
Expand Down Expand Up @@ -62,8 +46,8 @@ public bool Equals(KeyValuePair<string, IEnumerable<string>> x, KeyValuePair<str
.All(xValue =>
{
string[] headerValues = HttpHeadersCollection.ParseHttpHeaderValue(yValue).ToArray();
return !_valuePatternMatcher.HasValue && headerValues.Contains(xValue)
|| (_valuePatternMatcher.HasValue && headerValues.Any(_valuePatternMatcher.Value.IsMatch));
return (!_valuePatternMatcher.HasValue && headerValues.Contains(xValue))
|| (_valuePatternMatcher.HasValue && headerValues.Any(_valuePatternMatcher.Value.IsMatch));
})
))
{
Expand Down
19 changes: 19 additions & 0 deletions src/MockHttp/Http/HttpHeaderMatchType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace MockHttp.Http;

internal enum HttpHeaderMatchType
{
/// <summary>
/// Header and value(s) match exactly.
/// </summary>
Exact,

/// <summary>
/// Header name matches, values are ignored.
/// </summary>
HeaderNameOnly,

/// <summary>
/// Header name matches and all values of left comparand must be in right.
/// </summary>
HeaderNameAndPartialValues
}

0 comments on commit 76ac4e0

Please sign in to comment.