-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
Showing
25 changed files
with
195 additions
and
146 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("WireMock.Net.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e138ec44d93acac565953052636eb8d5e7e9f27ddb030590055cd1a0ab2069a5623f1f77ca907d78e0b37066ca0f6d63da7eecc3fcb65b76aa8ebeccf7ebe1d11264b8404cd9b1cbbf2c83f566e033b3e54129f6ef28daffff776ba7aebbc53c0d635ebad8f45f78eb3f7e0459023c218f003416e080f96a1a3c5ffeb56bee9e")] | ||
|
||
// Needed for Moq in the UnitTest project | ||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] |
64 changes: 64 additions & 0 deletions
64
src/WireMock.Net.ProtoBuf/RequestBuilders/IRequestBuilderExtensions.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,64 @@ | ||
// ReSharper disable InconsistentNaming | ||
using Stef.Validation; | ||
using WireMock.Matchers; | ||
using WireMock.Matchers.Request; | ||
|
||
namespace WireMock.RequestBuilders; | ||
|
||
/// <summary> | ||
/// IRequestBuilderExtensions extensions for GraphQL. | ||
/// </summary> | ||
public static class IRequestBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// WithGrpcProto | ||
/// </summary> | ||
/// <param name="requestBuilder">The <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="protoDefinition">The proto definition as text.</param> | ||
/// <param name="messageType">The full type of the protobuf (request/response) message object. Format is "{package-name}.{type-name}".</param> | ||
/// <param name="matchBehaviour">The match behaviour. (default = "AcceptOnMatch")</param> | ||
/// <returns>The <see cref="IRequestBuilder"/>.</returns> | ||
public static IRequestBuilder WithBodyAsProtoBuf(this IRequestBuilder requestBuilder, string protoDefinition, string messageType, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) | ||
{ | ||
return Guard.NotNull(requestBuilder).Add(new RequestMessageProtoBufMatcher(matchBehaviour, () => new(null, protoDefinition), messageType)); | ||
} | ||
|
||
/// <summary> | ||
/// WithGrpcProto | ||
/// </summary> | ||
/// <param name="requestBuilder">The <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="protoDefinition">The proto definition as text.</param> | ||
/// <param name="messageType">The full type of the protobuf (request/response) message object. Format is "{package-name}.{type-name}".</param> | ||
/// <param name="matcher">The matcher to use to match the ProtoBuf as (json) object.</param> | ||
/// <param name="matchBehaviour">The match behaviour. (default = "AcceptOnMatch")</param> | ||
/// <returns>The <see cref="IRequestBuilder"/>.</returns> | ||
public static IRequestBuilder WithBodyAsProtoBuf(this IRequestBuilder requestBuilder, string protoDefinition, string messageType, IObjectMatcher matcher, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) | ||
{ | ||
return Guard.NotNull(requestBuilder).Add(new RequestMessageProtoBufMatcher(matchBehaviour, () => new(null, protoDefinition), messageType, matcher)); | ||
} | ||
|
||
/// <summary> | ||
/// WithGrpcProto | ||
/// </summary> | ||
/// <param name="requestBuilder">The <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="messageType">The full type of the protobuf (request/response) message object. Format is "{package-name}.{type-name}".</param> | ||
/// <param name="matchBehaviour">The match behaviour. (default = "AcceptOnMatch")</param> | ||
/// <returns>The <see cref="IRequestBuilder"/>.</returns> | ||
public static IRequestBuilder WithBodyAsProtoBuf(this IRequestBuilder requestBuilder, string messageType, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) | ||
{ | ||
return Guard.NotNull(requestBuilder).Add(new RequestMessageProtoBufMatcher(matchBehaviour, () => requestBuilder.Mapping.ProtoDefinition!.Value, messageType)); | ||
} | ||
|
||
/// <summary> | ||
/// WithGrpcProto | ||
/// </summary> | ||
/// <param name="requestBuilder">The <see cref="IRequestBuilder"/>.</param> | ||
/// <param name="messageType">The full type of the protobuf (request/response) message object. Format is "{package-name}.{type-name}".</param> | ||
/// <param name="matcher">The matcher to use to match the ProtoBuf as (json) object.</param> | ||
/// <param name="matchBehaviour">The match behaviour. (default = "AcceptOnMatch")</param> | ||
/// <returns>The <see cref="IRequestBuilder"/>.</returns> | ||
public static IRequestBuilder WithBodyAsProtoBuf(this IRequestBuilder requestBuilder, string messageType, IObjectMatcher matcher, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) | ||
{ | ||
return Guard.NotNull(requestBuilder).Add(new RequestMessageProtoBufMatcher(matchBehaviour, () => requestBuilder.Mapping.ProtoDefinition!.Value, messageType, matcher)); | ||
} | ||
} |
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,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<Description>ProtoBuf and gRPC support for WireMock.Net</Description> | ||
<AssemblyTitle>WireMock.Net.ProtoBuf</AssemblyTitle> | ||
<Authors>Stef Heyenrath</Authors> | ||
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net6.0;net8.0</TargetFrameworks> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<PackageTags>wiremock;matchers;matcher;protobuf;grpc</PackageTags> | ||
<RootNamespace>WireMock</RootNamespace> | ||
<ProjectGuid>{B47413AA-55D3-49A7-896A-17ADBFF72407}</ProjectGuid> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> | ||
<CodeAnalysisRuleSet>../WireMock.Net/WireMock.Net.ruleset</CodeAnalysisRuleSet> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>../WireMock.Net/WireMock.Net.snk</AssemblyOriginatorKeyFile> | ||
<!--<DelaySign>true</DelaySign>--> | ||
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" PrivateAssets="All" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> | ||
<PackageReference Include="ProtoBufJsonConverter" Version="0.2.0" /> | ||
|
||
<ProjectReference Include="..\WireMock.Net\WireMock.Net.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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 |
---|---|---|
@@ -1,8 +1,25 @@ | ||
using System; | ||
using WireMock.Models; | ||
|
||
namespace WireMock.Matchers; | ||
|
||
/// <summary> | ||
/// IProtoBufMatcher | ||
/// </summary> | ||
public interface IProtoBufMatcher : IDecodeBytesMatcher, IBytesMatcher | ||
{ | ||
/// <summary> | ||
/// The Func to define the proto definition as text or id. | ||
/// </summary> | ||
public Func<IdOrText> ProtoDefinition { get; } | ||
|
||
/// <summary> | ||
/// The full type of the protobuf (request/response) message object. Format is "{package-name}.{type-name}". | ||
/// </summary> | ||
public string MessageType { get; } | ||
|
||
/// <summary> | ||
/// The Matcher to use (optional). | ||
/// </summary> | ||
public IObjectMatcher? Matcher { get; } | ||
} |
12 changes: 12 additions & 0 deletions
12
src/WireMock.Net/Matchers/Request/IRequestMessageProtoBufMatcher.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,12 @@ | ||
namespace WireMock.Matchers.Request; | ||
|
||
/// <summary> | ||
/// The request body ProtoBuf matcher. | ||
/// </summary> | ||
public interface IRequestMessageProtoBufMatcher : IRequestMatcher | ||
{ | ||
/// <summary> | ||
/// The ProtoBufMatcher. | ||
/// </summary> | ||
IProtoBufMatcher? Matcher { get; } | ||
} |
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
45 changes: 0 additions & 45 deletions
45
src/WireMock.Net/RequestBuilders/IProtoBufRequestBuilder.cs
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.