|
// 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 Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Recommendations
{
[Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
public class SizeOfKeywordRecommenderTests : KeywordRecommenderTests
{
[Fact]
public async Task TestAtRoot_Interactive()
{
await VerifyKeywordAsync(SourceCodeKind.Script,
@"$$");
}
[Fact]
public async Task TestAfterClass_Interactive()
{
await VerifyKeywordAsync(SourceCodeKind.Script,
"""
class C { }
$$
""");
}
[Fact]
public async Task TestAfterGlobalStatement_Interactive()
{
await VerifyKeywordAsync(SourceCodeKind.Script,
"""
System.Console.WriteLine();
$$
""");
}
[Fact]
public async Task TestAfterGlobalVariableDeclaration_Interactive()
{
await VerifyKeywordAsync(SourceCodeKind.Script,
"""
int i = 0;
$$
""");
}
[Fact]
public async Task TestNotInUsingAlias()
{
await VerifyAbsenceAsync(
@"using Goo = $$");
}
[Fact]
public async Task TestNotInGlobalUsingAlias()
{
await VerifyAbsenceAsync(
@"global using Goo = $$");
}
[Fact]
public async Task TestInsideEmptyMethod()
{
await VerifyKeywordAsync(AddInsideMethod(
@"$$"));
}
[Fact]
public async Task TestInsideSafeExpression()
{
await VerifyKeywordAsync(AddInsideMethod(
@"var q = $$"));
}
[Fact]
public async Task TestInsideUnsafeBlock()
{
await VerifyKeywordAsync(AddInsideMethod(
"""
unsafe {
$$
"""));
}
[Fact]
public async Task TestInsideUnsafeExpression()
{
await VerifyKeywordAsync(AddInsideMethod(
"""
unsafe {
var q = $$
"""));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544219")]
public async Task TestNotInObjectInitializerMemberContext()
{
await VerifyAbsenceAsync("""
class C
{
public int x, y;
void M()
{
var c = new C { x = 2, y = 3, $$
""");
}
[Fact]
public async Task TestAfterRefExpression()
{
await VerifyKeywordAsync(AddInsideMethod(
@"ref int x = ref $$"));
}
}
}
|