File: src\Servers\Kestrel\shared\test\MetricsAssert.cs
Web Access
Project: src\src\Servers\Kestrel\Core\test\Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj (Microsoft.AspNetCore.Server.Kestrel.Core.Tests)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
 
namespace Microsoft.AspNetCore.InternalTesting;
 
internal static class MetricsAssert
{
    public static void Equal(ConnectionEndReason expectedReason, string errorType)
    {
        Assert.Equal(KestrelMetrics.GetErrorType(expectedReason), errorType);
    }
 
    public static void Equal(ConnectionEndReason expectedReason, IReadOnlyDictionary<string, object> tags)
    {
        Equal(expectedReason, (string) tags[KestrelMetrics.ErrorTypeAttributeName]);
    }
 
    public static void NoError(IReadOnlyDictionary<string, object> tags)
    {
        if (tags.TryGetValue(KestrelMetrics.ErrorTypeAttributeName, out var error))
        {
            Assert.Fail($"Tag collection contains {KestrelMetrics.ErrorTypeAttributeName} with value {error}.");
        }
    }
}