public void When_InvalidCodeSupplied_Then_CompilationErrorsAreAccurate() { string code = @"usi ng System;"; CSharpCompilers.Compilation compilation = compiler.Compile(code); Assert.Equal(4, compilation.GetErrors().ToArray().Length); Assert.True(compilation.GetErrors().Exists(e => e.Id == "CS1002")); Assert.True(compilation.GetErrors().Exists(e => e.Id == "CS0116")); Assert.True(compilation.GetErrors().Exists(e => e.Id == "CS1022")); Assert.True(compilation.GetErrors().Exists(e => e.Id == "CS0246")); }
public void When_InvalidCodeSupplied_Then_CompilationFails() { string code = @"usi ng System;"; CSharpCompilers.Compilation compilation = compiler.Compile(code); Assert.NotEmpty(compilation.GetErrors()); }
public void When_CompilationErrors_And_RunCalled_Then_ExceptionThrown() { string code = @"usi ng System;"; CSharpCompilers.Compilation compilation = compiler.Compile(code); var e = Assert.Throws <CompilationError>(() => compilation.Run( new Compilation.RunOptions().WithNamespace("A").WithClass("B").WithMethod("C"))); Assert.Equal(e.Message, String.Concat(compilation.GetErrors())); }
public void TestCompile() { string code = File.ReadAllText(@"C:\Users\Ovidiu\Desktop\EventsToSpadNext\src\demo-scripts.cs"); Compiler compiler = new SPADNextCompiler(@"E:\SPAD.neXt\SPAD.Interfaces.dll"); CSharpCompilers.Compilation compilation = compiler.Compile(code); IEnumerable <Diagnostic> errors = compilation.GetErrors(); if (errors.Count() > 0) { foreach (Diagnostic diagnostic in errors) { LOG.WriteLine($"\t{diagnostic.Id}: {diagnostic.GetMessage()}"); } Assert.True(false, "Code compilation failed. See the test output logs for details."); } }
public void When_ValidCodeSupplied_Then_CompilationSucceeds() { CSharpCompilers.Compilation compilation = compiler.Compile(TestUtils.CODE); Assert.Empty(compilation.GetErrors()); }
public void When_EmptyCodeSupplied_Then_CompilationSucceeds() { CSharpCompilers.Compilation compilation = compiler.Compile(string.Empty); Assert.Empty(compilation.GetErrors()); }