public void Throw_OnNullRazorTemplate_OnCompile() { var compiler = new RoslynCompilationService(new DefaultMetadataReferenceManager(), Assembly.GetEntryAssembly()); Func <Assembly> action = () => compiler.CompileAndEmit(null); Assert.Throws <ArgumentNullException>(action); }
public void Throw_With_CompilationErrors_On_Failed_BuildAsync() { var compiler = new RoslynCompilationService(new DefaultMetadataReferenceManager(), Assembly.GetEntryAssembly()); var template = new TestGeneratedRazorTemplate("key", "public class Test { error }"); TemplateCompilationException ex = null; try { compiler.CompileAndEmit(template); } catch (TemplateCompilationException e) { ex = e; } Assert.NotNull(ex); Assert.NotEmpty(ex.CompilationErrors); Assert.Equal(1, ex.CompilationErrors.Count); }