Skip to content

Commit

Permalink
refactor(CA2208): rather, catch the invalid enum value in ctor.
Browse files Browse the repository at this point in the history
  • Loading branch information
skwasjer committed Nov 18, 2023
1 parent 1770c62 commit 5702763
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/MockHttp/Http/HttpHeaderEqualityComparer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MockHttp.Matchers.Patterns;
using System.ComponentModel;
using MockHttp.Matchers.Patterns;

namespace MockHttp.Http;

Expand All @@ -25,6 +26,11 @@ internal sealed class HttpHeaderEqualityComparer : IEqualityComparer<KeyValuePai

public HttpHeaderEqualityComparer(HttpHeaderMatchType matchType)
{
if (!Enum.IsDefined(typeof(HttpHeaderMatchType), matchType))
{
throw new InvalidEnumArgumentException(nameof(matchType), (int)matchType, typeof(HttpHeaderMatchType));
}

_matchType = matchType;
}

Expand Down Expand Up @@ -67,7 +73,7 @@ public bool Equals(KeyValuePair<string, IEnumerable<string>> x, KeyValuePair<str
return !x.Value.Any();
}
default:
throw new ArgumentOutOfRangeException();
return false;
}
}

Expand Down

0 comments on commit 5702763

Please sign in to comment.