Skip to content

Commit

Permalink
Rename method to indicate use only in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Aug 22, 2024
1 parent a780b34 commit 50f8c68
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task VerifyEditorConfigSettingsAreReadCorrectlyAsync()
";
var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("TestCompany", styleCopSettings.DocumentationRules.CompanyName);
Assert.Equal("Custom copyright text.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
Expand All @@ -80,7 +80,7 @@ public async Task VerifyFileHeaderTemplateFromEditorConfigAsync()
";
var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("Line 1\nLine 2.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
}
Expand All @@ -95,7 +95,7 @@ public async Task VerifyStyleCopDocumentationCopyrightTextFromEditorConfigAsync(
";
var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("Line 1\nLine 2.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
}
Expand All @@ -116,7 +116,7 @@ public async Task VerifyBooleanDocumentationSettingsFromEditorConfigAsync(bool v
";
var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal(value, styleCopSettings.DocumentationRules.DocumentExposedElements);
Assert.Equal(value, styleCopSettings.DocumentationRules.DocumentInternalElements);
Expand All @@ -137,7 +137,7 @@ public async Task VerifySettingsWillUseCompanyNameInDefaultCopyrightTextFromEdit
";
var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal(companyName, styleCopSettings.DocumentationRules.CompanyName);
Assert.Equal($"Copyright (c) {companyName}. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
Expand All @@ -153,7 +153,7 @@ public async Task VerifyCircularReferenceBehaviorFromEditorConfigAsync()
";
var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("[CircularReference]", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
}
Expand All @@ -168,7 +168,7 @@ public async Task VerifyInvalidReferenceBehaviorFromEditorConfigAsync()
";
var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("[InvalidReference]", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
}
Expand All @@ -191,7 +191,7 @@ public async Task VerifyEditorConfigSettingsReadCorrectlyDirectivePlacementWitho
";
var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.NotNull(styleCopSettings.OrderingRules);
Assert.Equal(expected, styleCopSettings.OrderingRules.UsingDirectivesPlacement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class SettingsUnitTests
[Fact]
public void VerifySettingsDefaults()
{
var styleCopSettings = SettingsHelper.GetStyleCopSettings(default(SyntaxTreeAnalysisContext), CancellationToken.None);
var styleCopSettings = SettingsHelper.GetStyleCopSettingsInTests(default(SyntaxTreeAnalysisContext), CancellationToken.None);

Assert.Equal("PlaceholderCompany", styleCopSettings.DocumentationRules.CompanyName);
Assert.Equal("Copyright (c) PlaceholderCompany. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
Expand Down Expand Up @@ -65,7 +65,7 @@ public async Task VerifyDefaultCultureIsReadCorrectlyAsync()
";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("en-US", styleCopSettings.DocumentationRules.DocumentationCulture);
Assert.Same(CultureInfo.InvariantCulture, styleCopSettings.DocumentationRules.DocumentationCultureInfo);
Expand Down Expand Up @@ -116,7 +116,7 @@ public async Task VerifySettingsAreReadCorrectlyAsync()
";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("TestCompany", styleCopSettings.DocumentationRules.CompanyName);
Assert.Equal("Custom copyright text.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
Expand Down Expand Up @@ -159,7 +159,7 @@ public async Task VerifyBooleanDocumentationSettingsAsync(bool value)
";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal(value, styleCopSettings.DocumentationRules.DocumentExposedElements);
Assert.Equal(value, styleCopSettings.DocumentationRules.DocumentInternalElements);
Expand Down Expand Up @@ -189,7 +189,7 @@ public async Task VerifyDocumentationVariablesAsync()
";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Single(styleCopSettings.DocumentationRules.Variables);
Assert.Equal("value", styleCopSettings.DocumentationRules.Variables["var"]);
Expand Down Expand Up @@ -217,7 +217,7 @@ public async Task VerifySettingsWillUseCompanyNameInDefaultCopyrightTextAsync(st
";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal(companyName, styleCopSettings.DocumentationRules.CompanyName);
Assert.Equal($"Copyright (c) {companyName}. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
Expand All @@ -237,7 +237,7 @@ public async Task VerifyCircularReferenceBehaviorAsync()
";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("[CircularReference]", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
}
Expand All @@ -256,7 +256,7 @@ public async Task VerifyInvalidReferenceBehaviorAsync()
";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("[InvalidReference]", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
}
Expand All @@ -280,7 +280,7 @@ public async Task VerifySettingsSupportsLineCommentsAsync()
";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("TestCompany", styleCopSettings.DocumentationRules.CompanyName);
Assert.Equal("Copyright (c) TestCompany. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
Expand All @@ -307,7 +307,7 @@ public async Task VerifySettingsSupportsBlockCommentsAsync()
";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("TestCompany", styleCopSettings.DocumentationRules.CompanyName);
Assert.Equal("Copyright (c) TestCompany. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
Expand All @@ -334,7 +334,7 @@ public async Task VerifySettingsSupportsTrailingCommasAsync()
";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("TestCompany", styleCopSettings.DocumentationRules.CompanyName);
Assert.Equal("Copyright (c) TestCompany. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused"));
Expand All @@ -357,7 +357,7 @@ public async Task VerifySettingsFileNameSupportsDotPrefixAsync()
";
var context = await CreateAnalysisContextAsync(settings, ".stylecop.json").ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

Assert.Equal("TestCompany", styleCopSettings.DocumentationRules.CompanyName);
}
Expand All @@ -368,7 +368,7 @@ public async Task VerifyInvalidJsonBehaviorAsync()
var settings = @"This is not a JSON file.";
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

// The result is the same as the default settings.
Assert.Equal("PlaceholderCompany", styleCopSettings.DocumentationRules.CompanyName);
Expand All @@ -381,7 +381,7 @@ public async Task VerifyEmptyOrMissingFileAsync()
var settings = string.Empty;
var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false);

var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None);
var styleCopSettings = context.GetStyleCopSettingsInTests(CancellationToken.None);

// The result is the same as the default settings.
Assert.Equal("PlaceholderCompany", styleCopSettings.DocumentationRules.CompanyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ internal static StyleCopSettings GetStyleCopSettings(this SyntaxTreeAnalysisCont
/// <param name="context">The context that will be used to determine the StyleCop settings.</param>
/// <param name="cancellationToken">The cancellation token that the operation will observe.</param>
/// <returns>A <see cref="StyleCopSettings"/> instance that represents the StyleCop settings for the given context.</returns>
internal static StyleCopSettings GetStyleCopSettings(this SyntaxTreeAnalysisContext context, CancellationToken cancellationToken)
internal static StyleCopSettings GetStyleCopSettingsInTests(this SyntaxTreeAnalysisContext context, CancellationToken cancellationToken)
{
var settingsFile = GetSettingsFile(context.Options, ParseJson, cancellationToken);
return GetSettings(context.Options, settingsStorage: new StrongBox<StyleCopSettings>(), context.Tree, settingsFile, DeserializationFailureBehavior.ReturnDefaultSettings);
Expand Down

0 comments on commit 50f8c68

Please sign in to comment.