Skip to content

Commit b582f7f

Browse files
committed
Refactor RangePrologue to a shared helper
1 parent 31030c7 commit b582f7f

2 files changed

Lines changed: 30 additions & 21 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1008CSharp8UnitTests.cs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules
88
using Microsoft.CodeAnalysis.CSharp;
99
using Microsoft.CodeAnalysis.Testing;
1010
using StyleCop.Analyzers.Test.CSharp7.SpacingRules;
11+
using StyleCop.Analyzers.Test.Verifiers;
1112
using Xunit;
1213

1314
using static StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly;
@@ -18,25 +19,6 @@ namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules
1819

1920
public class SA1008CSharp8UnitTests : SA1008CSharp7UnitTests
2021
{
21-
private const string RangePrologue = @"namespace System
22-
{
23-
public struct Range
24-
{
25-
public Range(Index a, Index b)
26-
{
27-
}
28-
public Index Start { get; }
29-
public Index End { get; }
30-
}
31-
32-
public struct Index
33-
{
34-
public static implicit operator Index(int value) => throw null;
35-
public int GetOffset(int length) => throw null;
36-
}
37-
}
38-
";
39-
4022
/// <summary>
4123
/// Verifies that spacing after a range expression double dots isn't required.
4224
/// </summary>
@@ -48,7 +30,7 @@ public struct Index
4830
[Fact]
4931
public async Task TestBeforeRangeExpressionAsync()
5032
{
51-
var testCode = RangePrologue + @"
33+
var testCode = SpecialTypeDefinitions.IndexAndRange + @"
5234
namespace TestNamespace
5335
{
5436
using System;
@@ -64,7 +46,7 @@ public string TestMethod()
6446
}
6547
";
6648

67-
var fixedCode = RangePrologue + @"
49+
var fixedCode = SpecialTypeDefinitions.IndexAndRange + @"
6850
namespace TestNamespace
6951
{
7052
using System;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+
namespace StyleCop.Analyzers.Test.Verifiers
5+
{
6+
internal static class SpecialTypeDefinitions
7+
{
8+
public const string IndexAndRange = @"namespace System
9+
{
10+
public struct Range
11+
{
12+
public Range(Index a, Index b)
13+
{
14+
}
15+
public Index Start { get; }
16+
public Index End { get; }
17+
}
18+
19+
public struct Index
20+
{
21+
public static implicit operator Index(int value) => throw null;
22+
public int GetOffset(int length) => throw null;
23+
}
24+
}
25+
";
26+
}
27+
}

0 commit comments

Comments
 (0)