Skip to content

Commit

Permalink
Tons of test changes to move them to the new Options APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mavasani committed Mar 10, 2020
1 parent e4c7e8e commit 7e3c47e
Show file tree
Hide file tree
Showing 116 changed files with 836 additions and 799 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ enum E
},
Options =
{
{ CodeStyleOptions.RequireAccessibilityModifiers, AccessibilityModifiersRequired.OmitIfDefault },
{ CodeStyleOptions2.RequireAccessibilityModifiers, AccessibilityModifiersRequired.OmitIfDefault },
},
}.RunAsync();
}
Expand All @@ -332,7 +332,7 @@ ref struct S1 { }
}",
Options =
{
{ CodeStyleOptions.RequireAccessibilityModifiers, AccessibilityModifiersRequired.OmitIfDefault },
{ CodeStyleOptions2.RequireAccessibilityModifiers, AccessibilityModifiersRequired.OmitIfDefault },
},
}.RunAsync();
}
Expand All @@ -354,7 +354,7 @@ readonly struct S1 { }
}",
Options =
{
{ CodeStyleOptions.RequireAccessibilityModifiers, AccessibilityModifiersRequired.OmitIfDefault },
{ CodeStyleOptions2.RequireAccessibilityModifiers, AccessibilityModifiersRequired.OmitIfDefault },
},
}.RunAsync();
}
Expand All @@ -370,7 +370,7 @@ internal class [|C1|] { }",
class C1 { }",
Options =
{
{ CodeStyleOptions.RequireAccessibilityModifiers, AccessibilityModifiersRequired.OmitIfDefault },
{ CodeStyleOptions2.RequireAccessibilityModifiers, AccessibilityModifiersRequired.OmitIfDefault },
},
}.RunAsync();
}
Expand Down
34 changes: 17 additions & 17 deletions src/EditorFeatures/CSharpTest/AddBraces/AddBracesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void Main()
}
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -61,7 +61,7 @@ static void Main()
}
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -81,7 +81,7 @@ static void Main()
return;
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -101,7 +101,7 @@ static void Main()
}
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -121,7 +121,7 @@ static void Main()
}
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -141,7 +141,7 @@ static void Main()
}
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -162,7 +162,7 @@ static void Main()
while (true);
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand Down Expand Up @@ -190,7 +190,7 @@ public void Dispose()
throw new NotImplementedException();
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand Down Expand Up @@ -225,7 +225,7 @@ public void Dispose()
throw new NotImplementedException();
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -246,7 +246,7 @@ static void Main()
}
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -267,7 +267,7 @@ static void Main()
return;
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -287,7 +287,7 @@ unsafe static void Main()
}
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand Down Expand Up @@ -1345,7 +1345,7 @@ static void Main()
return;
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -1368,7 +1368,7 @@ static void Main()
#endif
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand All @@ -1393,7 +1393,7 @@ static void Main()
return;
}
}",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption.Silent)));
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
}

[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
Expand Down Expand Up @@ -1826,11 +1826,11 @@ private async Task TestAsync(string initialMarkup, string expectedMarkup, Prefer
{
if (expectDiagnostic)
{
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup, options: Option(CSharpCodeStyleOptions.PreferBraces, bracesPreference, NotificationOption.Silent));
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup, options: Option(CSharpCodeStyleOptions.PreferBraces, bracesPreference, NotificationOption2.Silent));
}
else
{
await TestMissingInRegularAndScriptAsync(initialMarkup, new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, bracesPreference, NotificationOption.Silent)));
await TestMissingInRegularAndScriptAsync(initialMarkup, new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, bracesPreference, NotificationOption2.Silent)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public partial class AddRequiredParenthesesTests : AbstractCSharpDiagnosticProvi
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (new CSharpAddRequiredParenthesesDiagnosticAnalyzer(), new AddRequiredParenthesesCodeFixProvider());

private Task TestMissingAsync(string initialMarkup, IDictionary<OptionKey, object> options)
private Task TestMissingAsync(string initialMarkup, IOptionsCollection options)
=> TestMissingInRegularAndScriptAsync(initialMarkup, new TestParameters(options: options));

private Task TestAsync(string initialMarkup, string expected, IDictionary<OptionKey, object> options)
private Task TestAsync(string initialMarkup, string expected, IOptionsCollection options)
=> TestInRegularAndScript1Async(initialMarkup, expected, parameters: new TestParameters(options: options));

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddRequiredParentheses)]
Expand Down
4 changes: 2 additions & 2 deletions src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal async Task TestAsync(
string expectedMarkup,
int index = 0,
CodeActionPriority? priority = null,
IDictionary<OptionKey, object> options = null)
IOptionsCollection options = null)
{
await TestAsync(initialMarkup, expectedMarkup, index, priority, options, outOfProcess: false);
await TestAsync(initialMarkup, expectedMarkup, index, priority, options, outOfProcess: true);
Expand All @@ -55,7 +55,7 @@ internal async Task TestAsync(
string expectedMarkup,
int index,
CodeActionPriority? priority,
IDictionary<OptionKey, object> options,
IOptionsCollection options,
bool outOfProcess)
{
await TestInRegularAndScript1Async(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ private Task TestAsync(
bool systemSpecialCase,
int index = 0)
{
return TestInRegularAndScriptAsync(initialMarkup, expected, index: index, options: new Dictionary<OptionKey, object>
return TestInRegularAndScriptAsync(initialMarkup, expected, index: index, options: new Dictionary<OptionKey2, object>
{
{ new OptionKey(GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp), systemSpecialCase }
{ new OptionKey2(GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp), systemSpecialCase }
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,9 @@ public void man()
}
}
}";
var optionSet = new Dictionary<OptionKey, object>
var optionSet = new Dictionary<OptionKey2, object>
{
{ CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, false }
{ CSharpFormattingOptions2.NewLinesForBracesInObjectCollectionArrayInitializers, false }
};
using var session = CreateSession(code, optionSet);
Assert.NotNull(session);
Expand Down Expand Up @@ -621,9 +621,9 @@ class Goo
{
public int bar;
}";
var optionSet = new Dictionary<OptionKey, object>
var optionSet = new Dictionary<OptionKey2, object>
{
{ CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, false }
{ CSharpFormattingOptions2.NewLinesForBracesInObjectCollectionArrayInitializers, false }
};
using var session = CreateSession(code, optionSet);
Assert.NotNull(session);
Expand Down Expand Up @@ -692,9 +692,9 @@ public void man()
}
}
}";
var optionSet = new Dictionary<OptionKey, object>
var optionSet = new Dictionary<OptionKey2, object>
{
{ CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, false }
{ CSharpFormattingOptions2.NewLinesForBracesInObjectCollectionArrayInitializers, false }
};
using var session = CreateSession(code, optionSet);
Assert.NotNull(session);
Expand Down Expand Up @@ -753,9 +753,9 @@ public void man()
}
}
}";
var optionSet = new Dictionary<OptionKey, object>
var optionSet = new Dictionary<OptionKey2, object>
{
{ CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, false }
{ CSharpFormattingOptions2.NewLinesForBracesInObjectCollectionArrayInitializers, false }
};
using var session = CreateSession(code, optionSet);
Assert.NotNull(session);
Expand Down Expand Up @@ -814,9 +814,9 @@ public void man()
}
}
}";
var optionSet = new Dictionary<OptionKey, object>
var optionSet = new Dictionary<OptionKey2, object>
{
{ CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, false }
{ CSharpFormattingOptions2.NewLinesForBracesInObjectCollectionArrayInitializers, false }
};
using var session = CreateSession(code, optionSet);
Assert.NotNull(session);
Expand Down Expand Up @@ -879,10 +879,10 @@ public void X()
}
}";

var optionSet = new Dictionary<OptionKey, object>
var optionSet = new Dictionary<OptionKey2, object>
{
{ new OptionKey(FeatureOnOffOptions.AutoFormattingOnCloseBrace, LanguageNames.CSharp), false },
{ new OptionKey(FormattingOptions.SmartIndent, LanguageNames.CSharp), FormattingOptions.IndentStyle.Block }
{ new OptionKey2(FeatureOnOffOptions.AutoFormattingOnCloseBrace, LanguageNames.CSharp), false },
{ new OptionKey2(FormattingOptions2.SmartIndent, LanguageNames.CSharp), FormattingOptions.IndentStyle.Block }
};
using var session = CreateSession(code, optionSet);
Assert.NotNull(session);
Expand All @@ -909,9 +909,9 @@ public class C1
{ }
}";

var optionSet = new Dictionary<OptionKey, object>
var optionSet = new Dictionary<OptionKey2, object>
{
{ new OptionKey(FormattingOptions.SmartIndent, LanguageNames.CSharp), FormattingOptions.IndentStyle.None }
{ new OptionKey2(FormattingOptions2.SmartIndent, LanguageNames.CSharp), FormattingOptions.IndentStyle.None }
};
using var session = CreateSession(code, optionSet);
Assert.NotNull(session);
Expand Down Expand Up @@ -944,9 +944,9 @@ public class C1
}
}";

var optionSet = new Dictionary<OptionKey, object>
var optionSet = new Dictionary<OptionKey2, object>
{
{ new OptionKey(FormattingOptions.SmartIndent, LanguageNames.CSharp), FormattingOptions.IndentStyle.Block }
{ new OptionKey2(FormattingOptions2.SmartIndent, LanguageNames.CSharp), FormattingOptions.IndentStyle.Block }
};
using var session = CreateSession(code, optionSet);
Assert.NotNull(session);
Expand Down Expand Up @@ -987,9 +987,9 @@ public class C1
}
}";

var optionSet = new Dictionary<OptionKey, object>
var optionSet = new Dictionary<OptionKey2, object>
{
{ new OptionKey(FormattingOptions.SmartIndent, LanguageNames.CSharp), FormattingOptions.IndentStyle.Block }
{ new OptionKey2(FormattingOptions2.SmartIndent, LanguageNames.CSharp), FormattingOptions.IndentStyle.Block }
};
using var session = CreateSession(code, optionSet);
Assert.NotNull(session);
Expand All @@ -1000,7 +1000,7 @@ public class C1
CheckReturn(session.Session, 8, expectedAfterReturn);
}

internal Holder CreateSession(string code, Dictionary<OptionKey, object> optionSet = null)
internal Holder CreateSession(string code, Dictionary<OptionKey2, object> optionSet = null)
{
return CreateSession(
TestWorkspace.CreateCSharp(code),
Expand Down
Loading

0 comments on commit 7e3c47e

Please sign in to comment.