2020-12-20 08:36:11 +01:00
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
2020-05-14 20:59:29 +10:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2020-09-30 21:23:56 +02:00
|
|
|
using System.Threading.Tasks;
|
2020-12-20 08:36:11 +01:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Routing;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2020-09-30 21:23:56 +02:00
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Hosting.Internal;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2020-12-20 08:36:11 +01:00
|
|
|
using Moq;
|
2020-05-14 20:59:29 +10:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.Common.Routing
|
2020-05-14 20:59:29 +10:00
|
|
|
{
|
|
|
|
|
public class TestRouteBuilder : IEndpointRouteBuilder
|
|
|
|
|
{
|
|
|
|
|
private readonly ServiceProvider _serviceProvider;
|
|
|
|
|
|
|
|
|
|
public TestRouteBuilder()
|
|
|
|
|
{
|
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
services.AddLogging();
|
|
|
|
|
services.AddMvc();
|
2020-09-30 21:23:56 +02:00
|
|
|
services.AddSingleton<IHostApplicationLifetime>(x => new ApplicationLifetime(x.GetRequiredService<ILogger<ApplicationLifetime>>()));
|
|
|
|
|
services.AddSignalR();
|
2020-05-14 20:59:29 +10:00
|
|
|
_serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ICollection<EndpointDataSource> DataSources { get; } = new List<EndpointDataSource>();
|
|
|
|
|
|
|
|
|
|
public IServiceProvider ServiceProvider => _serviceProvider;
|
|
|
|
|
|
|
|
|
|
public IApplicationBuilder CreateApplicationBuilder()
|
|
|
|
|
{
|
2020-09-30 21:23:56 +02:00
|
|
|
var mock = new Mock<IApplicationBuilder>();
|
|
|
|
|
mock.Setup(x => x.Build()).Returns(httpContext => Task.CompletedTask);
|
|
|
|
|
return mock.Object;
|
2020-05-14 20:59:29 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|