public async Task GeneratesEnableModuleAttributesForAllModules() { StringBuilder builder = new(); foreach (DurianModule module in ModuleIdentity.GetAllModules().AsEnums()) { builder .Append("[assembly: Durian.Generator.EnableModule(Durian.Info.") .Append(nameof(DurianModule)) .Append('.') .Append(module.ToString()) .AppendLine(")]"); } CSharpSyntaxTree expected = (CSharpSyntaxTree)CSharpSyntaxTree.ParseText(builder.ToString()); CSharpCompilation compilation = RoslynUtilities.CreateBaseCompilation(); DisabledModuleAnalyzer analyzer = new(); await analyzer.RunAnalyzer(compilation); SingletonGeneratorTestResult result = GeneratorTest.RunGenerator("", analyzer); Assert.True(result.IsGenerated); Assert.NotNull(result.SyntaxTree); Assert.True(result.SyntaxTree !.IsEquivalentTo(expected)); }
public async Task ModulesAreEnabledByDefault() { CSharpCompilation compilation = RoslynUtilities.CreateBaseCompilation(); DisabledModuleAnalyzer analyzer = new(); await analyzer.RunAnalyzer(compilation); Assert.True(ModuleIdentity.GetAllModules().AsEnums().All(module => DisabledModuleAnalyzer.IsEnabled(module))); }