mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-27 11:51:56 +01:00
Use latest ProtoBufJsonConverter to support WellKnownTypes (#1161)
* Use latest ProtoBufJsonConverter to support WellKnownTypes * Fix * 02 * WireMockServer_WithBodyAsProtoBuf_WithWellKnownTypes * . * extra test * 0.4.0-preview-06 * 7 * <PackageReference Include="ProtoBufJsonConverter" Version="0.4.0-preview-08" /> * Update README.md * <PackageReference Include="ProtoBufJsonConverter" Version="0.4.0-preview-09" /> * <PackageReference Include="ProtoBufJsonConverter" Version="0.4.0" /> * Update README.md
This commit is contained in:
@@ -102,7 +102,7 @@ public class MatcherMapperTests
|
||||
// Assign
|
||||
var matcherMock = new Mock<IStringMatcher>();
|
||||
matcherMock.Setup(m => m.Name).Returns("test");
|
||||
matcherMock.Setup(m => m.GetPatterns()).Returns(new AnyOf<string, StringPattern>[] { "p1", "p2" });
|
||||
matcherMock.Setup(m => m.GetPatterns()).Returns(["p1", "p2"]);
|
||||
|
||||
// Act
|
||||
var model = _sut.Map(matcherMock.Object)!;
|
||||
@@ -206,7 +206,7 @@ public class MatcherMapperTests
|
||||
public void MatcherMapper_Map_Matcher_ProtoBufMatcher()
|
||||
{
|
||||
// Arrange
|
||||
IdOrText protoDefinition = new(null, @"
|
||||
IdOrTexts protoDefinition = new(null, @"
|
||||
syntax = ""proto3"";
|
||||
|
||||
package greet;
|
||||
@@ -235,7 +235,7 @@ message HelloReply {
|
||||
|
||||
// Assert
|
||||
model.Name.Should().Be(nameof(ProtoBufMatcher));
|
||||
model.Pattern.Should().Be(protoDefinition.Text);
|
||||
model.Pattern.Should().Be(protoDefinition.Texts[0]);
|
||||
model.ProtoBufMessageType.Should().Be(messageType);
|
||||
model.ContentMatcher?.Name.Should().Be("JsonMatcher");
|
||||
model.ContentMatcher?.Pattern.Should().Be(jsonPattern);
|
||||
@@ -246,7 +246,7 @@ message HelloReply {
|
||||
{
|
||||
// Arrange
|
||||
string id = "abc123";
|
||||
IdOrText protoDefinition = new(id, @"
|
||||
IdOrTexts protoDefinition = new(id, @"
|
||||
syntax = ""proto3"";
|
||||
|
||||
package greet;
|
||||
@@ -327,7 +327,7 @@ message HelloReply {
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "LinqMatcher",
|
||||
Patterns = new[] { "p1", "p2" }
|
||||
Patterns = ["p1", "p2"]
|
||||
};
|
||||
|
||||
// Act
|
||||
@@ -362,7 +362,7 @@ message HelloReply {
|
||||
{
|
||||
// Assign
|
||||
var pattern = "{ \"post1\": \"value1\", \"post2\": \"value2\" }";
|
||||
var patterns = new[] { pattern };
|
||||
object[] patterns = [pattern];
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "JsonMatcher",
|
||||
@@ -383,7 +383,7 @@ message HelloReply {
|
||||
// Assign
|
||||
var pattern1 = "{ \"AccountIds\": [ 1, 2, 3 ] }";
|
||||
var pattern2 = "{ \"post1\": \"value1\", \"post2\": \"value2\" }";
|
||||
var patterns = new[] { pattern1, pattern2 };
|
||||
object[] patterns = [pattern1, pattern2];
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "JsonMatcher",
|
||||
@@ -690,7 +690,7 @@ message HelloReply {
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "CSharpCodeMatcher",
|
||||
Patterns = new[] { "return it == \"x\";" }
|
||||
Patterns = ["return it == \"x\";"]
|
||||
};
|
||||
var sut = new MatcherMapper(new WireMockServerSettings { AllowCSharpCodeMatcher = true });
|
||||
|
||||
@@ -716,7 +716,7 @@ message HelloReply {
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "CSharpCodeMatcher",
|
||||
Patterns = new[] { "x" }
|
||||
Patterns = ["x"]
|
||||
};
|
||||
var sut = new MatcherMapper(new WireMockServerSettings { AllowCSharpCodeMatcher = false });
|
||||
|
||||
@@ -734,7 +734,7 @@ message HelloReply {
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "ExactMatcher",
|
||||
Patterns = new[] { "x" }
|
||||
Patterns = ["x"]
|
||||
};
|
||||
|
||||
// Act
|
||||
@@ -751,7 +751,7 @@ message HelloReply {
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "ExactMatcher",
|
||||
Patterns = new[] { "x", "y" }
|
||||
Patterns = ["x", "y"]
|
||||
};
|
||||
|
||||
// Act
|
||||
@@ -819,7 +819,7 @@ message HelloReply {
|
||||
var matcher = (ExactObjectMatcher)_sut.Map(model)!;
|
||||
|
||||
// Assert
|
||||
Check.That((byte[])matcher.Value).ContainsExactly(new byte[] { 115, 116, 101, 102 });
|
||||
Check.That((byte[])matcher.Value).ContainsExactly(115, 116, 101, 102);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -846,7 +846,7 @@ message HelloReply {
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "RegexMatcher",
|
||||
Patterns = new[] { "x", "y" },
|
||||
Patterns = ["x", "y"],
|
||||
IgnoreCase = true,
|
||||
MatchOperator = matchOperator.ToString()
|
||||
};
|
||||
@@ -871,7 +871,7 @@ message HelloReply {
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "WildcardMatcher",
|
||||
Patterns = new[] { "x", "y" },
|
||||
Patterns = ["x", "y"],
|
||||
IgnoreCase = true,
|
||||
MatchOperator = matchOperator.ToString()
|
||||
};
|
||||
@@ -1127,7 +1127,7 @@ message HelloReply {
|
||||
var matcher = (ProtoBufMatcher)_sut.Map(model)!;
|
||||
|
||||
// Assert
|
||||
matcher.ProtoDefinition().Text.Should().Be(protoDefinition);
|
||||
matcher.ProtoDefinition().Texts.Should().ContainSingle(protoDefinition);
|
||||
matcher.Name.Should().Be(nameof(ProtoBufMatcher));
|
||||
matcher.MessageType.Should().Be(messageType);
|
||||
matcher.Matcher?.Value.Should().Be(jsonMatcherPattern);
|
||||
|
||||
Reference in New Issue
Block a user