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:
Stef Heyenrath
2024-10-16 10:57:47 +02:00
committed by GitHub
parent ac693e0f96
commit 1682c61a0c
34 changed files with 530 additions and 153 deletions

View File

@@ -2,8 +2,8 @@
Guid: Guid_1,
UpdatedAt: 2022-12-04 11:12:13,
TimeSettings: {
Start: 2023-01-14 15:16:17,
End: 2023-01-14 15:17:57,
Start: 2023-01-14 15:16:17 Utc,
End: 2023-01-14 15:17:57 Utc,
TTL: 100
},
Title: ,

View File

@@ -226,7 +226,7 @@ message HelloReply {
public Task ToMappingModel_WithTimeSettings_ReturnsCorrectTimeSettings()
{
// Assign
var start = new DateTime(2023, 1, 14, 15, 16, 17);
var start = new DateTime(2023, 1, 14, 15, 16, 17, DateTimeKind.Utc);
var ttl = 100;
var end = start.AddSeconds(ttl);
var request = Request.Create();

View File

@@ -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);