public void InvalidCodeFailsToCompile() { FrameworkCompiler frameworkCompiler = new FrameworkCompiler(); CodeDomProvider codeDomProvider = new CSharpCodeProvider(); string script = @" public class ClassFromScript { this should cause code to fail }"; frameworkCompiler.Compile(codeDomProvider, script, new ArrayList()); }
public void ValidCodeCompilesSuccessfully() { FrameworkCompiler frameworkCompiler = new FrameworkCompiler(); CodeDomProvider codeDomProvider = new CSharpCodeProvider(); string script = @" public class ClassFromScript { public int zero = 0; }"; Assembly assembly = frameworkCompiler.Compile(codeDomProvider, script, new ArrayList()); Type type = assembly.GetType("ClassFromScript"); Assert.AreEqual(1, assembly.GetTypes().Length); Assert.AreEqual("ClassFromScript", type.FullName); }