/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Http/Http.Abstractions/test/HttpMethodslTests.cs
49 строк
2 KB
Copilot
Add HttpMethods.Query constant and IsQuery method to ASP.NET Core (#63260)
15 авг 2025, 05:17
Не верифицирован
15 авг 2025, 05:17
a768f1b
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Text; namespace Microsoft.AspNetCore.Http.Abstractions; public class HttpMethodslTests { [Fact] public void CanonicalizedValue_Success() { var testCases = new List<(string[] methods, string expectedMethod)> { (new string[] { "GET", "Get", "get" }, HttpMethods.Get), (new string[] { "POST", "Post", "post" }, HttpMethods.Post), (new string[] { "PUT", "Put", "put" }, HttpMethods.Put), (new string[] { "DELETE", "Delete", "delete" }, HttpMethods.Delete), (new string[] { "HEAD", "Head", "head" }, HttpMethods.Head), (new string[] { "CONNECT", "Connect", "connect" }, HttpMethods.Connect), (new string[] { "OPTIONS", "Options", "options" }, HttpMethods.Options), (new string[] { "PATCH", "Patch", "patch" }, HttpMethods.Patch), (new string[] { "QUERY", "Query", "query" }, HttpMethods.Query), (new string[] { "TRACE", "Trace", "trace" }, HttpMethods.Trace) }; for (int i = 0; i < testCases.Count; i++) { var testCase = testCases[i]; for (int j = 0; j < testCase.methods.Length; j++) { CanonicalizedValueTest(testCase.methods[j], testCase.expectedMethod); } } } private void CanonicalizedValueTest(string method, string expectedMethod) { string inputMethod = CreateStringAtRuntime(method); var canonicalizedValue = HttpMethods.GetCanonicalizedValue(inputMethod); Assert.Same(expectedMethod, canonicalizedValue); } private string CreateStringAtRuntime(string input) { return new StringBuilder(input).ToString(); } }