Beispiel #1
0
        public void Throw_OnNullRazorTemplate_OnCompile()
        {
            var compiler = new RoslynCompilationService(new DefaultMetadataReferenceManager(), Assembly.GetEntryAssembly());

            Func <Assembly> action = () => compiler.CompileAndEmit(null);

            Assert.Throws <ArgumentNullException>(action);
        }
Beispiel #2
0
        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);
        }