This commit is contained in:
Stef Heyenrath
2026-02-14 11:41:25 +01:00
parent 99f42fb255
commit 6cc18e796c
55 changed files with 164 additions and 398 deletions

View File

@@ -1,12 +1,7 @@
// Copyright © WireMock.Net
//#if PROTOBUF
using System;
using System.IO;
using System.Threading.Tasks;
using FluentAssertions;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Grpc;
@@ -24,11 +19,11 @@ public class ProtoBufUtilsTests
// Act
var responseBytes = await ProtoBufUtils.GetProtoBufMessageWithHeaderAsync(
[greet, request],
"greet.HelloRequest",
new
"greet.HelloRequest", new
{
name = "hello"
}
},
cancellationToken: TestContext.Current.CancellationToken
);
// Assert
@@ -39,5 +34,4 @@ public class ProtoBufUtilsTests
{
return File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "Grpc", filename));
}
}
//#endif
}

View File

@@ -1,12 +1,7 @@
// Copyright © WireMock.Net
//#if PROTOBUF
using System;
using System.IO;
using System.Threading.Tasks;
using FluentAssertions;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Grpc;
@@ -65,11 +60,11 @@ public class ProtoDefinitionHelperTests
{
rejected_spans = 1,
error_message = "abc"
}
},
cancellationToken: TestContext.Current.CancellationToken
);
// Assert
Convert.ToBase64String(responseBytes).Should().Be("AAAAAAcIARIDYWJj");
}
}
//#endif
}

View File

@@ -1,18 +1,14 @@
// Copyright © WireMock.Net
//#if PROTOBUF
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using ExampleIntegrationTest.Lookup;
using FluentAssertions;
using Google.Protobuf.WellKnownTypes;
using Greet;
using Grpc.Net.Client;
using ExampleIntegrationTest.Lookup;
using WireMock.Constants;
using WireMock.Matchers;
using WireMock.RequestBuilders;
@@ -20,7 +16,6 @@ using WireMock.ResponseBuilders;
using WireMock.Server;
using WireMock.Settings;
using WireMock.Util;
using Xunit;
// ReSharper disable once CheckNamespace
namespace WireMock.Net.Tests;
@@ -140,7 +135,7 @@ message Other {
protoBuf.Headers.ContentType = new MediaTypeHeaderValue("application/grpc-web");
var client = server.CreateClient();
var response = await client.PostAsync("/grpc/greet.Greeter/SayHello", protoBuf);
var response = await client.PostAsync("/grpc/greet.Greeter/SayHello", protoBuf, TestContext.Current.CancellationToken);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
@@ -178,7 +173,7 @@ message Other {
protoBuf.Headers.ContentType = new MediaTypeHeaderValue("application/grpc-web");
var client = server.CreateClient();
var response = await client.PostAsync("/grpc/greet.Greeter/SayHello", protoBuf);
var response = await client.PostAsync("/grpc/greet.Greeter/SayHello", protoBuf, TestContext.Current.CancellationToken);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
@@ -772,5 +767,4 @@ message Other {
{
return File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "Grpc", filename));
}
}
//#endif
}