Skip to content

Commit 51624cb

Browse files
committed
Use standard names in tests.
1 parent ef2e86f commit 51624cb

9 files changed

Lines changed: 68 additions & 60 deletions

File tree

IDisposableAnalyzers.Test/Helpers/Disposable.Disposes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ internal C(string fileName)
149149
public static void WhenAddedToFormComponents()
150150
{
151151
var code = @"
152-
namespace ValidCode
152+
namespace N
153153
{
154154
using System.IO;
155155
using System.Windows.Forms;

IDisposableAnalyzers.Test/Helpers/DisposableMemberTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected override void M()
7575
public static void FieldAddedToFormComponents(string expression)
7676
{
7777
var syntaxTree = CSharpSyntaxTree.ParseText(@"
78-
namespace ValidCode
78+
namespace N
7979
{
8080
using System.IO;
8181
using System.Windows.Forms;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
namespace IDisposableAnalyzers.Test.IDISP001DisposeCreatedTests
2+
{
3+
using Gu.Roslyn.Asserts;
4+
using NUnit.Framework;
5+
6+
public static partial class Valid<T>
7+
{
8+
[TestCase("this.components.Add(stream)")]
9+
[TestCase("components.Add(stream)")]
10+
public static void LocalAddedToFormComponents(string expression)
11+
{
12+
var code = @"
13+
namespace N
14+
{
15+
using System.IO;
16+
using System.Windows.Forms;
17+
18+
public class Winform : Form
19+
{
20+
Winform()
21+
{
22+
var stream = File.OpenRead(string.Empty);
23+
// Since this is added to components, it is automatically disposed of with the form.
24+
this.components.Add(stream);
25+
}
26+
}
27+
}".AssertReplace("this.components.Add(stream)", expression);
28+
RoslynAssert.NoAnalyzerDiagnostics(Analyzer, code);
29+
}
30+
31+
[TestCase("this.components.Add(this.stream)")]
32+
[TestCase("components.Add(stream)")]
33+
public static void FieldAddedToFormComponents(string expression)
34+
{
35+
var code = @"
36+
namespace N
37+
{
38+
using System.IO;
39+
using System.Windows.Forms;
40+
41+
public class Winform : Form
42+
{
43+
private readonly Stream stream;
44+
45+
Winform()
46+
{
47+
this.stream = File.OpenRead(string.Empty);
48+
// Since this is added to components, it is automatically disposed of with the form.
49+
this.components.Add(this.stream);
50+
}
51+
}
52+
}".AssertReplace("this.components.Add(this.stream)", expression);
53+
RoslynAssert.NoAnalyzerDiagnostics(Analyzer, code);
54+
}
55+
}
56+
}

IDisposableAnalyzers.Test/IDISP001DisposeCreatedTests/Valid.cs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -586,53 +586,5 @@ public Pair(T item1, T item2)
586586

587587
RoslynAssert.Valid(Analyzer, code);
588588
}
589-
590-
[TestCase("this.components.Add(stream)")]
591-
[TestCase("components.Add(stream)")]
592-
public static void LocalAddedToFormComponents(string expression)
593-
{
594-
var code = @"
595-
namespace ValidCode
596-
{
597-
using System.IO;
598-
using System.Windows.Forms;
599-
600-
public class Winform : Form
601-
{
602-
Winform()
603-
{
604-
var stream = File.OpenRead(string.Empty);
605-
// Since this is added to components, it is automatically disposed of with the form.
606-
this.components.Add(stream);
607-
}
608-
}
609-
}".AssertReplace("this.components.Add(stream)", expression);
610-
RoslynAssert.NoAnalyzerDiagnostics(Analyzer, code);
611-
}
612-
613-
[TestCase("this.components.Add(this.stream)")]
614-
[TestCase("components.Add(stream)")]
615-
public static void FieldAddedToFormComponents(string expression)
616-
{
617-
var code = @"
618-
namespace ValidCode
619-
{
620-
using System.IO;
621-
using System.Windows.Forms;
622-
623-
public class Winform : Form
624-
{
625-
private readonly Stream stream;
626-
627-
Winform()
628-
{
629-
this.stream = File.OpenRead(string.Empty);
630-
// Since this is added to components, it is automatically disposed of with the form.
631-
this.components.Add(this.stream);
632-
}
633-
}
634-
}".AssertReplace("this.components.Add(this.stream)", expression);
635-
RoslynAssert.NoAnalyzerDiagnostics(Analyzer, code);
636-
}
637589
}
638590
}

IDisposableAnalyzers.Test/IDISP002DisposeMemberTests/Valid.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ public void TearDown()
881881
public static void Issue150()
882882
{
883883
var code = @"
884-
namespace ValidCode
884+
namespace N
885885
{
886886
using System.Collections.Generic;
887887
using System.IO;
@@ -1070,7 +1070,7 @@ protected override void M()
10701070
public static void LocalAddedToFormComponents(string expression)
10711071
{
10721072
var code = @"
1073-
namespace ValidCode
1073+
namespace N
10741074
{
10751075
using System.IO;
10761076
using System.Windows.Forms;
@@ -1093,7 +1093,7 @@ public class Winform : Form
10931093
public static void FieldAddedToFormComponents(string expression)
10941094
{
10951095
var code = @"
1096-
namespace ValidCode
1096+
namespace N
10971097
{
10981098
using System.IO;
10991099
using System.Windows.Forms;

IDisposableAnalyzers.Test/IDISP003DisposeBeforeReassigningTests/Valid.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ public C1 GetOrCreateFoo()
14131413
public static void LocalAddedToFormComponents(string expression)
14141414
{
14151415
var code = @"
1416-
namespace ValidCode
1416+
namespace N
14171417
{
14181418
using System.IO;
14191419
using System.Windows.Forms;
@@ -1436,7 +1436,7 @@ public class Winform : Form
14361436
public static void FieldAddedToFormComponents(string expression)
14371437
{
14381438
var code = @"
1439-
namespace ValidCode
1439+
namespace N
14401440
{
14411441
using System.IO;
14421442
using System.Windows.Forms;

IDisposableAnalyzers.Test/IDISP004DoNotIgnoreCreatedTests/Valid.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ public async Task M()
796796
public static void LocalAddedToFormComponents(string expression)
797797
{
798798
var code = @"
799-
namespace ValidCode
799+
namespace N
800800
{
801801
using System.IO;
802802
using System.Windows.Forms;
@@ -819,7 +819,7 @@ public class Winform : Form
819819
public static void FieldAddedToFormComponents(string expression)
820820
{
821821
var code = @"
822-
namespace ValidCode
822+
namespace N
823823
{
824824
using System.IO;
825825
using System.Windows.Forms;

IDisposableAnalyzers.Test/IDISP006ImplementIDisposableTests/ValidCode.Inheritance.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ protected override void M()
219219
public static void LocalAddedToFormComponents(string expression)
220220
{
221221
var code = @"
222-
namespace ValidCode
222+
namespace N
223223
{
224224
using System.IO;
225225
using System.Windows.Forms;
@@ -242,7 +242,7 @@ public class Winform : Form
242242
public static void FieldAddedToFormComponents(string expression)
243243
{
244244
var code = @"
245-
namespace ValidCode
245+
namespace N
246246
{
247247
using System.IO;
248248
using System.Windows.Forms;

IDisposableAnalyzers.Test/IDISP006ImplementIDisposableTests/ValidCode.Repro.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void Dispose()
125125
public static void Issue150()
126126
{
127127
var code = @"
128-
namespace ValidCode
128+
namespace N
129129
{
130130
using System.Collections.Generic;
131131
using System.IO;

0 commit comments

Comments
 (0)