Skip to content

Commit

Permalink
Use of RegexGuid in the RegexMatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
brogdogg committed Dec 8, 2021
1 parent 5512fb7 commit e3bcd43
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/WireMock.Net/Matchers/RegexMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using JetBrains.Annotations;
using WireMock.Extensions;
using WireMock.Models;
using WireMock.RegularExpressions;
using WireMock.Validation;

namespace WireMock.Matchers
Expand All @@ -17,7 +18,7 @@ namespace WireMock.Matchers
public class RegexMatcher : IStringMatcher, IIgnoreCaseMatcher
{
private readonly AnyOf<string, StringPattern>[] _patterns;
private readonly Regex[] _expressions;
private readonly RegexGuid[] _expressions;

/// <inheritdoc cref="IMatcher.MatchBehaviour"/>
public MatchBehaviour MatchBehaviour { get; }
Expand Down Expand Up @@ -76,7 +77,7 @@ public RegexMatcher(MatchBehaviour matchBehaviour, [NotNull, RegexPattern] AnyOf
options |= RegexOptions.IgnoreCase;
}

_expressions = patterns.Select(p => new Regex(p.GetPattern(), options)).ToArray();
_expressions = patterns.Select(p => new RegexGuid(p.GetPattern(), options)).ToArray();
}

/// <inheritdoc cref="IStringMatcher.IsMatch"/>
Expand Down
9 changes: 0 additions & 9 deletions test/WireMock.Net.Tests/RegularExpressions/RegexGuidTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using NFluent;
using WireMock.Matchers;
using WireMock.Matchers.Request;
using WireMock.RegularExpressions;
using WireMock.RequestBuilders;
using Xunit;

namespace WireMock.Net.Tests.RegularExpressions
Expand All @@ -15,7 +12,6 @@ public class RegexGuidTests
/// </summary>
public Guid InputGuid { get; } = Guid.NewGuid();


[Fact]
public void RegexGuid_GuidB_Pattern()
{
Expand All @@ -33,7 +29,6 @@ public void RegexGuid_GuidB_Pattern()
Check.That(regexUpper.IsMatch(inputLower)).Equals(false);
}


[Fact]
public void RegexGuid_GuidD_Pattern()
{
Expand All @@ -51,7 +46,6 @@ public void RegexGuid_GuidD_Pattern()
Check.That(regexUpper.IsMatch(inputLower)).Equals(false);
}


[Fact]
public void RegexGuid_GuidN_Pattern()
{
Expand All @@ -69,7 +63,6 @@ public void RegexGuid_GuidN_Pattern()
Check.That(regexUpper.IsMatch(inputLower)).Equals(false);
}


[Fact]
public void RegexGuid_GuidP_Pattern()
{
Expand All @@ -87,7 +80,6 @@ public void RegexGuid_GuidP_Pattern()
Check.That(regexUpper.IsMatch(inputLower)).Equals(false);
}


[Fact]
public void RegexGuid_GuidX_Pattern()
{
Expand All @@ -105,6 +97,5 @@ public void RegexGuid_GuidX_Pattern()
Check.That(regexUpper.IsMatch(inputLower)).Equals(false);
}


}
}

0 comments on commit e3bcd43

Please sign in to comment.