// 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 System; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNet.Server.Kestrel.Http; namespace Microsoft.AspNet.Server.KestrelTests { class TestInput : IConnectionControl, IFrameControl { public TestInput() { var memory = new MemoryPool(); var memory2 = new MemoryPool2(); FrameContext = new FrameContext { SocketInput = new SocketInput(memory2), Memory = memory, ConnectionControl = this, FrameControl = this }; } public FrameContext FrameContext { get; set; } public void Add(string text, bool fin = false) { var encoding = System.Text.Encoding.ASCII; var count = encoding.GetByteCount(text); var buffer = FrameContext.SocketInput.Pin(text.Length); count = encoding.GetBytes(text, 0, text.Length, buffer.Data.Array, buffer.Data.Offset); FrameContext.SocketInput.Unpin(count); FrameContext.SocketInput.SetCompleted(null); if (fin) { FrameContext.SocketInput.RemoteIntakeFin = true; } } public void ProduceContinue() { } public void Pause() { } public void Resume() { } public void Write(ArraySegment data, Action callback, object state) { } public void End(ProduceEndType endType) { } void IFrameControl.ProduceContinue() { } void IFrameControl.Write(ArraySegment data) { } async Task IFrameControl.WriteAsync(ArraySegment data, CancellationToken cancellationToken) { } void IFrameControl.Flush() { } async Task IFrameControl.FlushAsync(CancellationToken cancellationToken) { } } }