-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f98cb5
commit 1915b96
Showing
12 changed files
with
556 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PactNet.Matchers | ||
{ | ||
public class ArrayContainsMatcher : IMatcher | ||
{ | ||
/// <summary> | ||
/// Type of the matcher | ||
/// </summary> | ||
[JsonPropertyName("pact:matcher:type")] | ||
public string Type => "array-contains"; | ||
|
||
/// <summary> | ||
/// The items expected to be in the array. | ||
/// </summary> | ||
[JsonPropertyName("variants")] | ||
public dynamic Value { get; } | ||
|
||
public ArrayContainsMatcher(dynamic[] variants) | ||
{ | ||
Value = variants; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/PactNet.Abstractions.Tests/Matchers/ArrayContainsMatcherTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Text.Json; | ||
using FluentAssertions; | ||
using PactNet.Matchers; | ||
using Xunit; | ||
|
||
namespace PactNet.Abstractions.Tests.Matchers | ||
{ | ||
public class ArrayContainsMatcherTests | ||
{ | ||
[Fact] | ||
public void Ctor_String_SerializesCorrectly() | ||
{ | ||
// Arrange | ||
var example = new[] | ||
{ | ||
"Thing1", | ||
"Thing2", | ||
}; | ||
|
||
var matcher = new ArrayContainsMatcher(example); | ||
|
||
// Act | ||
var actual = JsonSerializer.Serialize(matcher); | ||
|
||
// Assert | ||
actual.Should().Be(@"{""pact:matcher:type"":""array-contains"",""variants"":[""Thing1"",""Thing2""]}"); | ||
} | ||
} | ||
} |
Oops, something went wrong.