public void DefaultConstructorInitializeCorrectly() { var compilation = CSharpCompilation.Create("fakecompilation"); var fakeProject = new MockCompilationProject(); var fakeFramework = new FrameworkName(".NET Framework, Version=8.0"); var fakeConfiguration = "fakeConfiguration"; var resourceResolverInvoked = false; var context = new CompilationContext( compilation, fakeProject, fakeFramework, fakeConfiguration, new List <IMetadataReference>(), () => { resourceResolverInvoked = true; return(new List <CodeAnalysis.ResourceDescription>()); }); Assert.NotNull(context.Modules); Assert.Equal(0, context.Modules.Count); Assert.Equal(compilation, context.Compilation); Assert.Equal(compilation, context.BeforeCompileContext.Compilation); Assert.Equal(fakeProject, context.Project); Assert.Equal(fakeFramework, context.ProjectContext.TargetFramework); Assert.Equal(fakeConfiguration, context.ProjectContext.Configuration); Assert.False(resourceResolverInvoked, "Resource resolver should not be invoked"); Assert.Equal(0, context.Resources.Count); Assert.True(resourceResolverInvoked); var newCompilation = compilation.Clone(); context.Compilation = newCompilation; Assert.NotEqual(compilation, context.Compilation); Assert.NotEqual(compilation, context.BeforeCompileContext.Compilation); Assert.Equal(newCompilation, context.Compilation); Assert.Equal(newCompilation, context.BeforeCompileContext.Compilation); }
public void DefaultConstructorInitializeCorrectly() { var compilation = CSharpCompilation.Create("fakecompilation"); var fakeProject = new MockCompilationProject(); var fakeFramework = new FrameworkName(".NET Framework, Version=8.0"); var fakeConfiguration = "fakeConfiguration"; var resourceResolverInvoked = false; var context = new CompilationContext( compilation, fakeProject, fakeFramework, fakeConfiguration, new List<IMetadataReference>(), () => { resourceResolverInvoked = true; return new List<CodeAnalysis.ResourceDescription>(); }); Assert.NotNull(context.Modules); Assert.Equal(0, context.Modules.Count); Assert.Equal(compilation, context.Compilation); Assert.Equal(compilation, context.BeforeCompileContext.Compilation); Assert.Equal(fakeProject, context.Project); Assert.Equal(fakeFramework, context.ProjectContext.TargetFramework); Assert.Equal(fakeConfiguration, context.ProjectContext.Configuration); Assert.False(resourceResolverInvoked, "Resource resolver should not be invoked"); Assert.Equal(0, context.Resources.Count); Assert.True(resourceResolverInvoked); var newCompilation = compilation.Clone(); context.Compilation = newCompilation; Assert.NotEqual(compilation, context.Compilation); Assert.NotEqual(compilation, context.BeforeCompileContext.Compilation); Assert.Equal(newCompilation, context.Compilation); Assert.Equal(newCompilation, context.BeforeCompileContext.Compilation); }