Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantic snippets tests #74808

Merged
merged 20 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Compile Include="..\..\..\..\Features\DiagnosticsTestUtilities\CodeActions\VisualBasicCodeRefactoringVerifier`1.cs" Link="VisualBasicCodeRefactoringVerifier`1.cs" />
<Compile Include="..\..\..\..\Features\DiagnosticsTestUtilities\Diagnostics\ParenthesesOptionsProvider.cs" Link="ParenthesesOptionsProvider.cs" />
<Compile Include="..\..\..\..\Features\DiagnosticsTestUtilities\NamingStyles\NamingStylesTestOptionSets.cs" Link="NamingStyles\NamingStylesTestOptionSets.cs" />
<Compile Include="..\..\..\..\Features\DiagnosticsTestUtilities\Utilities\StringSyntaxAttribute.cs" Link="Utilities\StringSyntaxAttribute.cs" />
<Compile Include="..\..\..\..\Features\TestUtilities\Utilities\StringSyntaxAttribute.cs" Link="Utilities\StringSyntaxAttribute.cs" />
<Compile Include="..\..\..\..\Workspaces\CoreTestUtilities\OptionsCollection.cs" Link="OptionsCollection.cs" />
</ItemGroup>
<ItemGroup Label="Project References">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// 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;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Completion.CompletionProviders.Snippets;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion.CompletionProviders;

[Trait(Traits.Feature, Traits.Features.Completion)]
public sealed class SemanticSnippetCompletionProviderTests : AbstractCSharpCompletionProviderTests
{
public SemanticSnippetCompletionProviderTests()
{
ShowNewSnippetExperience = true;
}

internal override Type GetCompletionProviderType()
=> typeof(CSharpSnippetCompletionProvider);

[WpfFact]
public async Task InsertConsoleSnippetWithInvocationBeforeAndAfterCursorTest()
{
var markupBeforeCommit = """
class Program
{
public void Method()
{
Wr$$Blah
}
}
""";

var expectedCodeAfterCommit = """
using System;

class Program
{
public void Method()
{
Console.WriteLine($$);
}
}
""";

await VerifyCustomCommitProviderAsync(markupBeforeCommit, "cw", expectedCodeAfterCommit);
}

[WpfFact]
public async Task InsertConsoleSnippetWithInvocationUnderscoreBeforeAndAfterCursorTest()
{
var markupBeforeCommit =
"""
class Program
{
public void Method()
{
_Wr$$Blah_
}
}
""";

var expectedCodeAfterCommit =
"""
using System;

class Program
{
public void Method()
{
Console.WriteLine($$);
}
}
""";
await VerifyCustomCommitProviderAsync(markupBeforeCommit, "cw", expectedCodeAfterCommit);
}
}

This file was deleted.

This file was deleted.

Loading
Loading