/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Features/CSharpTest/Snippets/CSharpLockSnippetProviderTests.cs
184 строки
4 KB
Cyrus Najmabadi
Make tests non-async
08 июл 2025, 01:59
08 июл 2025, 01:59
c0736fd
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Threading.Tasks; using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Snippets; [Trait(Traits.Feature, Traits.Features.Snippets)] public sealed class CSharpLockSnippetProviderTests : AbstractCSharpSnippetProviderTests { protected override string SnippetIdentifier => "lock"; [Fact] public Task InsertLockSnippetInMethodTest() => VerifySnippetAsync(""" class Program { public void Method() { $$ } } """, """ class Program { public void Method() { lock ({|0:this|}) { $$ } } } """); [Fact] public Task InsertLockSnippetInGlobalContextTest() => VerifySnippetAsync(""" $$ """, """ lock ({|0:this|}) { $$ } """); [Fact] public Task NoLockSnippetInBlockNamespaceTest() => VerifySnippetIsAbsentAsync(""" namespace Namespace { $$ } """); [Fact] public Task NoLockSnippetInFileScopedNamespaceTest() => VerifySnippetIsAbsentAsync(""" namespace Namespace; $$ """); [Fact] public Task InsertLockSnippetInConstructorTest() => VerifySnippetAsync(""" class Program { public Program() { $$ } } """, """ class Program { public Program() { lock ({|0:this|}) { $$ } } } """); [Fact] public Task NoLockSnippetInTypeBodyTest() => VerifySnippetIsAbsentAsync(""" class Program { $$ } """); [Fact] public Task InsertLockSnippetInLocalFunctionTest() => VerifySnippetAsync(""" class Program { public void Method() { void LocalFunction() { $$ } } } """, """ class Program { public void Method() { void LocalFunction() { lock ({|0:this|}) { $$ } } } } """); [Fact] public Task InsertLockSnippetInAnonymousFunctionTest() => VerifySnippetAsync(""" class Program { public void Method() { var action = delegate() { $$ }; } } """, """ class Program { public void Method() { var action = delegate() { lock ({|0:this|}) { $$ } }; } } """); [Fact] public Task InsertLockSnippetInParenthesizedLambdaExpressionTest() => VerifySnippetAsync(""" class Program { public void Method() { var action = () => { $$ }; } } """, """ class Program { public void Method() { var action = () => { lock ({|0:this|}) { $$ } }; } } """); }