aspnetcore/test/shared/TestServiceContext.cs

31 lines
1.1 KiB
C#

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Testing
{
public class TestServiceContext : ServiceContext
{
public TestServiceContext()
{
var logger = new TestApplicationErrorLogger();
Log = new TestKestrelTrace(logger);
ThreadPool = new LoggingThreadPool(Log);
DateHeaderValueManager = new DateHeaderValueManager(systemClock: new MockSystemClock());
DateHeaderValue = DateHeaderValueManager.GetDateHeaderValues().String;
HttpParserFactory = frame => new KestrelHttpParser(frame.ServiceContext.Log);
ServerOptions = new KestrelServerOptions
{
AddServerHeader = false
};
}
public string DateHeaderValue { get; }
}
}