public void Throw_OnNullRazorTemplate_OnCompile() { var compiler = new RoslynCompilationService(new DefaultMetadataReferenceManager(), Assembly.GetEntryAssembly()); Func <Task> action = () => compiler.CompileAsync(null); Assert.ThrowsAsync <ArgumentNullException>(action); }
public async Task 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 { await compiler.CompileAsync(template); } catch (TemplateCompilationException e) { ex = e; } Assert.NotNull(ex); Assert.NotEmpty(ex.CompilationErrors); Assert.Equal(1, ex.CompilationErrors.Count); }