コード例 #1
0
ファイル: ManagerTests.cs プロジェクト: piotrstenke/Durian
        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));
        }
コード例 #2
0
ファイル: ManagerTests.cs プロジェクト: piotrstenke/Durian
        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)));
        }