-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
Copy pathIntegrationTestBase.cs
40 lines (30 loc) · 1.14 KB
/
IntegrationTestBase.cs
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Net.Http;
using IntegrationTestsWebsite;
using Microsoft.AspNetCore.Grpc.JsonTranscoding.IntegrationTests.Infrastructure;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;
namespace Microsoft.AspNetCore.Grpc.JsonTranscoding.IntegrationTests;
public class IntegrationTestBase : IClassFixture<GrpcTestFixture<Startup>>, IDisposable
{
private HttpClient? _channel;
private IDisposable? _testContext;
protected GrpcTestFixture<Startup> Fixture { get; set; }
protected ILoggerFactory LoggerFactory => Fixture.LoggerFactory;
protected HttpClient Channel => _channel ??= CreateChannel();
protected HttpClient CreateChannel()
{
return new HttpClient(Fixture.Handler);
}
public IntegrationTestBase(GrpcTestFixture<Startup> fixture, ITestOutputHelper outputHelper)
{
Fixture = fixture;
_testContext = Fixture.GetTestContext(outputHelper);
}
public void Dispose()
{
_testContext?.Dispose();
_channel = null;
}
}