示例#1
0
        public void CompileFrom_GivenEmptyCode_ShouldThrowException()
        {
            var compiler = new PluginCompiler(Mock.Of <IAssemblyReferenceProvider>());

            compiler.Invoking(c => c.CompileFrom(null)).ShouldThrow <ArgumentException>();
            compiler.Invoking(c => c.CompileFrom(string.Empty)).ShouldThrow <ArgumentException>();
        }
        public void CompileFrom_GivenEmptyCode_ShouldThrowException()
        {
            var compiler = new PluginCompiler(Mock.Of<IAssemblyReferenceProvider>());

            compiler.Invoking(c => c.CompileFrom(null)).ShouldThrow<ArgumentException>();
            compiler.Invoking(c => c.CompileFrom(string.Empty)).ShouldThrow<ArgumentException>();
        }
示例#3
0
        public void CompileFrom_GivenSourceCodeWithErrors_ShouldThrowException()
        {
            const string sourceCode        = @"namespace Test { public class Foo { public void Bar() { System.Console.WriteLine(""Bar."") } } }";
            var          mscorlibReference = MetadataReference.CreateFromFile(typeof(int).Assembly.Location);
            var          compiler          = new PluginCompiler(Mock.Of <IAssemblyReferenceProvider>(provider
                                                                                                     => provider.CollectMetadataReferences(It.IsAny <Assembly>()) == mscorlibReference.AsEnumerable()));

            compiler.Invoking(c => c.CompileFrom(sourceCode)).ShouldThrow <PluginCompilationException>();
        }
        public void CompileFrom_GivenSourceCodeWithErrors_ShouldThrowException()
        {
            const string sourceCode = @"namespace Test { public class Foo { public void Bar() { System.Console.WriteLine(""Bar."") } } }";
            var mscorlibReference = MetadataReference.CreateFromFile(typeof(int).Assembly.Location);
            var compiler = new PluginCompiler(Mock.Of<IAssemblyReferenceProvider>(provider
                => provider.CollectMetadataReferences(It.IsAny<Assembly>()) == mscorlibReference.AsEnumerable()));

            compiler.Invoking(c => c.CompileFrom(sourceCode)).ShouldThrow<PluginCompilationException>();
        }