11using System . Reflection ;
2- using System . Runtime . InteropServices ;
32using EnumClass . Attributes ;
4- using EnumClass . Core ;
53using Microsoft . CodeAnalysis ;
64using Microsoft . CodeAnalysis . CSharp ;
75
86namespace EnumClass . Generator . Tests ;
97
10- public class EnumClassGenerationTests
8+ public class EnumClassGeneratorTests
119{
1210 [ Fact ]
13- public void WithSingleMember__ShouldGenerateCorrectly ( )
11+ public void WithSingleMember__ShouldGenerateWithoutErrors ( )
1412 {
1513 var source = @"using EnumClass.Attributes;
1614
@@ -29,27 +27,27 @@ public enum SampleEnum: byte
2927
3028 MetadataReference . CreateFromFile ( Assembly . GetCallingAssembly ( ) . Location ) ,
3129 MetadataReference . CreateFromFile ( typeof ( string ) . Assembly . Location ) ,
32- // MetadataReference.CreateFromFile(Assembly.Load(new AssemblyName("System.Linq.Expressions")).Location),
3330 MetadataReference . CreateFromFile ( Assembly . Load ( new AssemblyName ( "System.Runtime" ) ) . Location ) ,
3431 MetadataReference . CreateFromFile ( Assembly . Load ( new AssemblyName ( "netstandard" ) ) . Location ) ,
3532 } , new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
3633
37- var driver = CSharpGeneratorDriver . Create ( new EnumClassIncrementalGenerator ( ) )
38- . RunGenerators ( compilation ) ;
34+ CSharpGeneratorDriver . Create ( new EnumClassIncrementalGenerator ( ) )
35+ . RunGeneratorsAndUpdateCompilation ( compilation , out _ , out var diagnostics ) ;
36+ Assert . Empty ( diagnostics . Where ( d => d . Severity == DiagnosticSeverity . Error ) ) ;
3937 }
4038
4139
4240 [ Fact ]
43- public void WithTwoMembers__ShouldGenerateCorrectly ( )
41+ public void WithSpecifiedAttributeArguments__ShouldGenerateWithoutErrors ( )
4442 {
4543 var source = @"using EnumClass.Attributes;
4644
4745namespace Test;
4846
4947[EnumClass(Namespace = ""Test"", ClassName = ""SampleEnum"")]
50- public enum SampleEnum: long
48+ public enum SampleEnum
5149{
52- Manager = long.MaxValue - 4 ,
50+ Manager,
5351 Programmer,
5452 Tester,
5553 CTO,
@@ -67,7 +65,8 @@ public enum SampleEnum: long
6765 MetadataReference . CreateFromFile ( Assembly . Load ( new AssemblyName ( "netstandard" ) ) . Location ) ,
6866 } , new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
6967
70- var driver = CSharpGeneratorDriver . Create ( new EnumClassIncrementalGenerator ( ) )
71- . RunGenerators ( compilation ) ;
68+ CSharpGeneratorDriver . Create ( new EnumClassIncrementalGenerator ( ) )
69+ . RunGeneratorsAndUpdateCompilation ( compilation , out _ , out var diagnostics ) ;
70+ Assert . Empty ( diagnostics . Where ( d => d . Severity == DiagnosticSeverity . Error ) ) ;
7271 }
7372}
0 commit comments