-
Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathGrpcGreeterTest.cs
More file actions
52 lines (46 loc) · 1.54 KB
/
GrpcGreeterTest.cs
File metadata and controls
52 lines (46 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.IO;
using FluentAssertions;
using PactNet;
using PactNet.Exceptions;
using PactNet.Infrastructure.Outputters;
using Xunit;
using PactNet.Output.Xunit;
using PactNet.Verifier;
using Xunit.Abstractions;
namespace GrpcGreeter.Tests
{
public class GrpcGreeterTests(ITestOutputHelper output, ServerFixture serverFixture) : IClassFixture<ServerFixture>, IDisposable
{
private readonly PactVerifier verifier = new("Grpc Greeter Api", new PactVerifierConfig
{
LogLevel = PactLogLevel.Information,
Outputters = new List<IOutput>
{
new XunitOutput(output)
}
});
private readonly string pactPath = Path.Combine("..", "..", "..", "..", "..", "Grpc", "pacts",
"grpc-greeter-client-grpc-greeter.json");
[Fact]
public void VerificationThrowsExceptionWhenNoRunningProvider()
{
var source = this.verifier
.WithHttpEndpoint(new Uri("http://localhost:5060"))
.WithFileSource(new FileInfo(this.pactPath));
source.Invoking(s => s.Verify()).Should().Throw<PactVerificationFailedException>();
}
[Fact]
public void VerificationSuccessForRunningProvider()
{
verifier.WithHttpEndpoint(serverFixture.ProviderUri)
.WithFileSource(new FileInfo(pactPath))
.Verify();
}
public void Dispose()
{
this.verifier?.Dispose();
}
}
}