-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathAgentTester.cs
35 lines (31 loc) · 1.77 KB
/
AgentTester.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
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef
using Microsoft.Extensions.DependencyInjection;
using System;
using UnitTestEx;
using UnitTestEx.AspNetCore;
namespace Beef.Test.NUnit
{
/// <summary>
/// Provides existing <c>Test</c> methods to support backwards compatibility.
/// </summary>
/// <remarks>It is <b>recommended</b> that usage is upgraded to the new <see cref="ApiTester.Create{TEntryPoint}"/> as this will eventually be deprecated.</remarks>
public static class AgentTester
{
/// <summary>
/// Creates an <see cref="AgentTester{TEntryPoint}"/> to support agent-initiated API testing.
/// </summary>
/// <typeparam name="TEntryPoint">The API startup <see cref="Type"/>.</typeparam>
/// <param name="configureServices">Provides an opportunity to configure the <see cref="IServiceCollection"/>.</param>
/// <param name="configureTester">Provides an opportunity to configure the owning <see cref="ApiTester{TEntryPoint}"/></param>
/// <returns>The <see cref="AgentTester{TEntryPoint}"/>.</returns>
/// <remarks>It is <b>recommended</b> that usage is upgraded to the new <see cref="ApiTester.Create{TEntryPoint}"/> as this will eventually be deprecated.</remarks>
public static AgentTester<TEntryPoint> CreateWaf<TEntryPoint>(Action<IServiceCollection>? configureServices = null, Action<ApiTester<TEntryPoint>>? configureTester = null) where TEntryPoint : class
{
var tester = ApiTester.Create<TEntryPoint>();
configureTester?.Invoke(tester);
if (configureServices != null)
tester.ConfigureServices(configureServices);
return new AgentTester<TEntryPoint>(tester);
}
}
}