// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices;

namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution;

internal sealed class ConsoleErrorRouter : ConsoleRouter
{
    public ConsoleErrorRouter(TextWriter originalConsoleErr, Func<TestOutputCaptureMode> modeProvider)
        : base(originalConsoleErr, modeProvider)
    {
    }

    protected override void WriteToTestContext(TestContextImplementation testContext, char value)
        => testContext.StandardErrorBuilder.Append(value);

    protected override void WriteToTestContext(TestContextImplementation testContext, string? value)
        => testContext.StandardErrorBuilder.Append(value);

    protected override void WriteToTestContext(TestContextImplementation testContext, char[] buffer, int index, int count)
        => testContext.StandardErrorBuilder.Append(buffer, index, count);
}
