<commit_before>﻿// 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.Editor.UnitTests.SpellCheck;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.SpellCheck
{
    [UseExportProvider]
    public class SpellCheckFixerProviderTests : AbstractSpellCheckFixerProviderTests
    {
        protected override TestWorkspace CreateWorkspace(string content)
            => TestWorkspace.CreateCSharp(content);

        [WpfFact]
        public async Task TestRenameClassName()
        {
            await TestSuccessAsync(
                """
                class {|CorrectlySpelled:CrrectlySpelled|}
                {
                    public CrrectlySpelled() { }
                }
                """,
                """
                class CorrectlySpelled
                {
                    public CorrectlySpelled() { }
                }
                """);
        }

        [WpfFact]
        public async Task TestBogusLocation()
        {
            // Should not be called inside a string.  But we should still apply the change.
            await TestFailureAsync(
                """
                class C
                {
                    void M()
                    {
                        var v1 = "{|word:wrd|}";
                        var v2 = "wrd";
                    }
                }
                """,
                """
                class C
                {
                    void M()
                    {
                        var v1 = "word";
                        var v2 = "wrd";
                    }
                }
                """);
        }

        [WpfFact]
        public async Task TestReplacementThatLanguageDoesNotSupport()
        {
            // Should not be called inside a string.  But we should still apply the change.
            await TestFailureAsync(
                """
                class {|Bo()gus:Orginal|}
                {
                    public Orginal() { }
                }
                """,
                """
                class Bo()gus
                {
                    public Orginal() { }
                }
                """);
        }

        [WpfFact]
        public async Task TestReplacementSpanLargerThanToken()
        {
            // Replacement span is larger than the lang token to rename.
            await TestFailureAsync(
                """
                class {|Replacement:Class |}
                {
                    public Class() { }
                }
                """,
                """
                class Replacement 
                {
                    public Class() { }
                }
                """);
        }
    }
}
<commit_msg>Fix test<commit_after>﻿// 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.Editor.UnitTests.SpellCheck;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.SpellCheck
{
    [UseExportProvider]
    public class SpellCheckFixerProviderTests : AbstractSpellCheckFixerProviderTests
    {
        protected override TestWorkspace CreateWorkspace(string content)
            => TestWorkspace.CreateCSharp(content);

        [WpfFact]
        public async Task TestRenameClassName()
        {
            await TestSuccessAsync(
                """
                class {|CorrectlySpelled:CrrectlySpelled|}
                {
                    public CrrectlySpelled() { }
                }
                """,
                """
                class CorrectlySpelled
                {
                    public CorrectlySpelled() { }
                }
                """);
        }

        [WpfFact]
        public async Task TestBogusLocation()
        {
            // Should not be called inside a string.  But we should still apply the change.
            await TestFailureAsync(
                """
                class C
                {
                    void M()
                    {
                        var v1 = "{|word:wrd|}";
                        var v2 = "wrd";
                    }
                }
                """,
                """
                class C
                {
                    void M()
                    {
                        var v1 = "word";
                        var v2 = "wrd";
                    }
                }
                """);
        }

        [WpfFact]
        public async Task TestReplacementThatLanguageDoesNotSupport()
        {
            // Should not be called inside a string.  But we should still apply the change.
            await TestFailureAsync(
                """
                class {|Bo()gus:Orginal|}
                {
                    public Orginal() { }
                }
                """,
                """
                class Bo()gus
                {
                    public Orginal() { }
                }
                """);
        }

        [WpfFact]
        public async Task TestReplacementSpanLargerThanToken()
        {
            // Replacement span is larger than the lang token to rename.
            await TestFailureAsync(
                """
                class {|Replacement:Class |}
                {
                    public Class() { }
                }
                """,
                """
                class Replacement
                {
                    public Class() { }
                }
                """);
        }
    }
}

{'fraction_non_alphanumeric': 0.07947454844006568, 'fraction_numerical': 0.0013136288998357964, 'mean_word_length': 1.0095677994061365, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3022184', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1349, 'n_words': 335}