11using System ;
22using System . Collections . Generic ;
3+ using System . Collections . Immutable ;
34using System . IO ;
45using System . Linq ;
56using System . Reflection ;
@@ -20,46 +21,61 @@ public class FormattingEngineCreationTests
2021 typeof ( FormattingEngine ) . Assembly ,
2122 typeof ( OptimizeNamespaceImportsAnalyzer ) . Assembly
2223 } ;
23- // TODO: fix hardcoded path
24- private static string TestDLLDir = @"E:\src\codeformatter\src\Microsoft.DotNet.CodeFormatting.Tests\TestAnalyzers\" ;
25- private static Assembly RoslynV100Analyzer = Assembly . LoadFile ( TestDLLDir + "RoslynV100Analyzer.dll" ) ;
26- private static Assembly RoslynV110Analyzer = Assembly . LoadFile ( TestDLLDir + "RoslynV110Analyzer.dll" ) ;
27- private static Assembly RoslynV111Analyzer = Assembly . LoadFile ( TestDLLDir + "RoslynV111Analyzer.dll" ) ;
28- private static Assembly RoslynV120Beta1Analyzer = Assembly . LoadFile ( TestDLLDir + "RoslynV120Beta1Analyzer.dll" ) ;
24+
25+ private static string TestDLLDir = Path . Combine ( Directory . GetCurrentDirectory ( ) , "TestAnalyzers" ) ;
26+ private static string RoslynV100Analyzer = Path . Combine ( TestDLLDir , "RoslynV100Analyzer.dll" ) ;
27+ private static string RoslynV110Analyzer = Path . Combine ( TestDLLDir , "RoslynV110Analyzer.dll" ) ;
28+ private static string RoslynV111Analyzer = Path . Combine ( TestDLLDir , "RoslynV111Analyzer.dll" ) ;
29+ private static string RoslynV120Beta1Analyzer = Path . Combine ( TestDLLDir , "RoslynV120Beta1Analyzer.dll" ) ;
30+ private static string RoslynV120VBAnalyzer = Path . Combine ( TestDLLDir , "RoslynV120VBAnalyzer.dll" ) ;
2931
3032 [ Fact ]
3133 public void AnalyzersBuiltAgainstRoslynV100 ( )
3234 {
33- IEnumerable < Assembly > roslynV1AnalyzerDLL = new Assembly [ ] { RoslynV100Analyzer } ;
35+ IFormattingEngine engine = FormattingEngine . Create ( DefaultCompositionAssemblies ) ;
3436 Assert . DoesNotThrow ( ( ) => {
35- var assemblies = DefaultCompositionAssemblies . Concat ( roslynV1AnalyzerDLL ) ;
37+ var analyzers = Program . AddCustomAnalyzers ( engine , ImmutableArray . Create ( RoslynV100Analyzer ) ) ;
38+ Assert . Equal ( 1 , analyzers . Count ( ) ) ;
3639 } ) ;
3740 }
3841
3942 [ Fact ]
4043 public void AnalyzersBuiltAgainstRoslynV110 ( )
4144 {
42- IEnumerable < Assembly > roslynV110AnalyzerDLL = new Assembly [ ] { RoslynV110Analyzer } ;
45+ IFormattingEngine engine = FormattingEngine . Create ( DefaultCompositionAssemblies ) ;
4346 Assert . DoesNotThrow ( ( ) => {
44- var assemblies = DefaultCompositionAssemblies . Concat ( roslynV110AnalyzerDLL ) ;
47+ var analyzers = Program . AddCustomAnalyzers ( engine , ImmutableArray . Create ( RoslynV110Analyzer ) ) ;
48+ Assert . Equal ( 1 , analyzers . Count ( ) ) ;
4549 } ) ;
4650 }
4751
4852 [ Fact ]
4953 public void AnalyzersBuiltAgainstRoslynV111 ( )
5054 {
51- IEnumerable < Assembly > roslynV111AnalyzerDLL = new Assembly [ ] { RoslynV111Analyzer } ;
55+ IFormattingEngine engine = FormattingEngine . Create ( DefaultCompositionAssemblies ) ;
5256 Assert . DoesNotThrow ( ( ) => {
53- var assemblies = DefaultCompositionAssemblies . Concat ( roslynV111AnalyzerDLL ) ;
57+ var analyzers = Program . AddCustomAnalyzers ( engine , ImmutableArray . Create ( RoslynV111Analyzer ) ) ;
58+ Assert . Equal ( 1 , analyzers . Count ( ) ) ;
5459 } ) ;
5560 }
5661
5762 [ Fact ]
5863 public void AnalyzersBuiltAgainstRoslynV120Beta1 ( )
5964 {
60- IEnumerable < Assembly > roslynV120Beta1AnalyzerDLL = new Assembly [ ] { RoslynV120Beta1Analyzer } ;
65+ IFormattingEngine engine = FormattingEngine . Create ( DefaultCompositionAssemblies ) ;
66+ Assert . DoesNotThrow ( ( ) => {
67+ var analyzers = Program . AddCustomAnalyzers ( engine , ImmutableArray . Create ( RoslynV120Beta1Analyzer ) ) ;
68+ Assert . Equal ( 1 , analyzers . Count ( ) ) ;
69+ } ) ;
70+ }
71+
72+ [ Fact ]
73+ public void AnalyzersBuiltAgainstRoslynV120 ( )
74+ {
75+ IFormattingEngine engine = FormattingEngine . Create ( DefaultCompositionAssemblies ) ;
6176 Assert . DoesNotThrow ( ( ) => {
62- var assemblies = DefaultCompositionAssemblies . Concat ( roslynV120Beta1AnalyzerDLL ) ;
77+ var analyzers = Program . AddCustomAnalyzers ( engine , ImmutableArray . Create ( RoslynV120VBAnalyzer ) ) ;
78+ Assert . Equal ( 1 , analyzers . Count ( ) ) ;
6379 } ) ;
6480 }
6581 }
0 commit comments