public void CanGetCompiler() { var compiler = Compilers.Get(EngineCodes.SqlServer); Assert.NotNull(compiler); Assert.IsType <SqlServerCompiler>(compiler); }
public ActionResult Index() { logger.Debug("User " + WebSecurity.GetUserId(User.Identity.Name) + " \"" + User.Identity.Name + "\" visited TestersManagement/Compilers/Index"); ManageCompilersViewModel viewModel = new ManageCompilersViewModel(); viewModel.Compilers = new List <Compiler>(); repository.ProgrammingLanguages.Each(c => { if (c.ProgrammingLanguageID != ProgrammingLanguages.Open) { viewModel.Compilers.Add(new Compiler() { CompilerID = c.ProgrammingLanguageID, Name = c.Title, Command = Compilers.GetCommand(c.ProgrammingLanguageID), Options = Compilers.GetOptions(c.ProgrammingLanguageID), Available = c.Available, Enable = c.Enable }); } }); return(View(viewModel)); }
public void ParseTest() { var correctXmlFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Compilers\CPP8\CPP8.xml"); var incorrectXmlFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Compilers\CsSharp\CSharp.xml"); var compilers = new Compilers("Compilers"); var privateObject = new PrivateObject(compilers, new PrivateType(typeof(Compilers))); // incorrect xml file try { privateObject.Invoke("Parse", incorrectXmlFilePath); Assert.AreEqual(true, false); } catch (Exception) { Assert.AreEqual(true, true); } // correct xml file try { Assert.AreNotEqual(null, privateObject.Invoke("Parse", correctXmlFilePath)); } catch (Exception) { Assert.AreEqual(true, false); } }
public void BasicSelect_WithNoTableWhereRawClause() { var q = new Query().Select("c1").WhereRaw("1 = 1"); var c = Compilers.CompileFor(EngineCodes.SqlServer, q); Assert.Equal("SELECT [c1] WHERE 1 = 1", c.ToString()); }
public void CompilersConstructorTest() { string compilersDirectory = null; Compilers target; try { target = new Compilers(compilersDirectory); Assert.AreEqual(true, false); } catch (Exception) { Assert.AreEqual(true, true); } try { compilersDirectory = "Directory"; target = new Compilers(compilersDirectory); Assert.AreEqual(true, true); } catch (Exception) { Assert.AreEqual(true, false); } }
public void AddCompilerTest() { var compilersDirectory = "Directory"; Compilers target; try { target = new Compilers(compilersDirectory); target.AddCompiler(null); Assert.AreEqual(false, true); } catch (Exception) { Assert.AreEqual(true, true); } try { target = new Compilers(compilersDirectory); Assert.AreEqual(target.Count, 0); target.AddCompiler(new Compiler()); Assert.AreEqual(target.Count, 1); } catch (Exception) { Assert.AreEqual(true, false); } }
public void CanCompile() { var results = Compilers.Compile(new Query("Table")); Assert.NotNull(results); Assert.Equal(Compilers.KnownEngineCodes.Count(), results.Count); }
/// <summary> /// Send data asynchronously. /// /// Thread safety. /// </summary> /// <param name="data"></param> protected void Send(byte[] Data, int Length) { try { // Begin sending the data to the remote client. _socket.BeginSend(Data, 0, Length, SocketFlags.None, new AsyncCallback(SendCallback), this); } catch (SocketException ex) { _logger.Warn("Error occurred on socket begin send: ", ex); if (!_socket.IsConnected()) { try { IsConnected = false; _timer.Stop(); _clientCompilers.Each(c => { Compilers.RemoveLanguage(c); if (!Compilers.AvailableLanguages.Contains(c)) { _repository.MakeProgrammingLanguageUnavailable(c); } }); _clientCompilers.Clear(); _socket.Shutdown(SocketShutdown.Both); _socket.Close(); _logger.Info(Address + ": Disconnected:", ex); } catch (Exception) { } } } }
public override void Initialize(IApp app) { base.Initialize(app); Compilers.ForEach(b => { if (b.Type.GetInterface(typeof(IBackgroundCompiler).Name) == null) { throw new ElideException("Compiler '{0}' doesn't implement IBackgroundCompiler interface.", b.Type); } var bc = TypeCreator.New <IBackgroundCompiler>(b.Type); var inf = (EditorInfo)app.GetService <IEditorService>().GetInfo("editors", b.EditorKey); var ins = inf.Instance as ICodeEditor; if (ins == null) { throw new ElideException("Compiler '{0}' can be only registered for the code editor.", b.Type); } var sci = ins.Control as ScintillaControl; var wrap = new BackgroundCompiler(app, sci, bc, this); CompilerInstances.Add(b.EditorKey, wrap); }); app.GetService <IDaemonService>().RegisterDaemon(this); app.GetService <IDocumentService>().DocumentAdded += (_, e) => DocumentOpened(e.Document); }
/// <summary> /// New implementation of the Init function, to allocate a BuildProject instance rather than a /// CompilationProject. /// </summary> /// <param name="path">The path of the file to parser</param> /// <param name="format">The resulting document format</param> /// <returns>The BuildProject instance created</returns> public new BuildProject Init(string path, DocumentFormat format = null) { FileCompiler compiler; if (Compilers.TryGetValue(path, out compiler)) { return(m_Projects[path]); } string directory = Directory.GetParent(path).FullName; string filename = Path.GetFileName(path); DirectoryInfo root = new DirectoryInfo(directory); if (format == null) { format = GetFormat(path); } TypeCobolOptions options = new TypeCobolOptions(); BuildProject project = new BuildProject(BuilderEngine, path, root.FullName, new string[] { "*.cbl", "*.cpy" }, format.Encoding, format.EndOfLineDelimiter, format.FixedLineLength, format.ColumnsLayout, options); m_Projects[path] = project; compiler = new FileCompiler(null, filename, project.SourceFileProvider, project, format.ColumnsLayout, options, CustomSymbols, false); Compilers.Add(path, compiler); Inits.Add(path, false); return(project); }
public void teste1() { String text = File.ReadAllText("script1.txt"); String[] references = new String[] { "System.dll", "mscorlib.dll" }; String srt = Generator.GenerateFullClass(references, null, "azulteste", "bla", text, "Method"); Console.WriteLine(srt); StreamWriter sw = File.CreateText("teste.cs"); sw.Write(srt); sw.Close(); String erro; Assembly Assembly = Compilers.GenerateAssembly(srt, references, out erro); if (erro != null) { MessageBox.Show(erro); return; } Executor.Execute("azulteste.bla", Assembly, "Method"); Console.ReadLine(); }
public void OffsetSqlServer_Should_Be_Ignored_If_Zero_Or_Negative(int offset) { var q = new Query().From("users").Offset(offset); var c = Compilers.CompileFor(EngineCodes.SqlServer, q); Assert.Equal("SELECT * FROM [users]", c.ToString()); }
/// <summary> /// 添加编译器 /// </summary> /// <param name="name"></param> /// <param name="compiler"></param> public virtual void AddCompiler(string name, ICompiler compiler) { if (Compilers.ContainsKey(name)) { return; } Compilers.Add(name, compiler); }
/// <summary> /// 得到编译器 /// </summary> /// <param name="dataBase"></param> /// <returns></returns> public virtual ICompiler GetCompiler(OrmDataBaseInfo dataBase) { if (string.IsNullOrEmpty(dataBase.CompilerName) || !Compilers.ContainsKey(dataBase.CompilerName)) { return(Compilers.FirstOrDefault().Value); } return(Compilers[dataBase.CompilerName]); }
public void BasicSelectRaw_WithNoTable() { var q = new Query().SelectRaw("somefunction() as c1"); var c = Compilers.CompileFor(EngineCodes.SqlServer, q); Assert.Equal("SELECT somefunction() as c1", c.ToString()); }
public void AddInvalidCompilerTest() { //create compilers with bad path var compilers = new Compilers("NoFolderCompilers"); //try to initialize them compilers.Load(); }
public void OffsetSqlServer_Should_Be_Incremented_By_One(int offset) { var q = new Query().From("users").Offset(offset); var c = Compilers.CompileFor(EngineCodes.SqlServer, q); Assert.Equal( "SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS [row_num] FROM [users]) AS [results_wrapper] WHERE [row_num] >= " + (offset + 1), c.ToString()); }
public void AddInvalidCompilerTest() { //create compilers with bad path var compilers = new Compilers("NoFolderCompilers"); //try to initialize them compilers.Load(); //there is no Assert, because in this test we are expecting an exception. }
public void AddDuplicateCompilerTest() { var firstCompilers = new Compilers("Compilers"); firstCompilers.Load(); firstCompilers.AddCompiler(firstCompilers.GetCompiler("CPP8")); //compilers must be unique. same compiler can not be added. Assert.AreEqual(firstCompilers.Count, 4); }
public void CanCompileSelectively() { var desiredEngines = new[] { EngineCodes.SqlServer, EngineCodes.MySql }; var results = Compilers.Compile(desiredEngines, new Query("Table")); Assert.Equal(desiredEngines.Length, results.Count); Assert.Contains(results, a => a.Key == EngineCodes.SqlServer); Assert.Contains(results, a => a.Key == EngineCodes.MySql); }
public void ParseTest() { var correctXmlFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Compilers\CPP8\CPP8.xml"); // TODO: check it var compilersArr = new Compilers("Compilers"); var privateObject = new PrivateObject(compilersArr, new PrivateType(typeof(Compilers))); Assert.AreNotEqual(null, privateObject.Invoke("Parse", correctXmlFilePath)); }
public void ClearTest() { var target = new Compilers("Directory"); Assert.AreEqual(target.Count, 0); target.AddCompiler(new Compiler()); Assert.AreEqual(target.Count, 1); target.Clear(); Assert.AreEqual(target.Count, 0); }
public void LoadTest() { var compilers = new Compilers("EmptyCompiler"); compilers.Load(); Assert.AreEqual(compilers.Count, 0); compilers = new Compilers("Compilers"); compilers.Load(); Assert.AreEqual(compilers.Count, 4); }
public void AddDuplicateCompilerTest() { //creating Compilers from compilers folder var firstCompilers = new Compilers("Compilers"); //initialization firstCompilers.Load(); //trying to add compiler of CPP8 which actually is in Compilers right now ! firstCompilers.AddCompiler(firstCompilers.GetCompiler("CPP8")); //compilers must be unique. same compiler can not be added, thats why test fails yet. Assert.AreEqual(firstCompilers.Count, 4); }
private bool init() { LoggerManaged.InitNativeLogger(new LoggerManaged.LogEventHandler(LogManager.GetLogger("Native").Log)); logger.Debug("Current directory is {0}", Directory.GetCurrentDirectory()); logger.Debug("AppData folder is {0}", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); logger.Debug("Current user is {0}", System.Security.Principal.WindowsIdentity.GetCurrent().Name); FileProvider.Init(); if (!Compilers.Init()) { logger.Error("Compilers initialization failed"); return(false); } if (Configuration.WorkerId == Guid.Empty) { if (!signUp()) { logger.Error("Application sign up failed"); return(false); } } var status = apiClient.SignIn(Configuration.WorkerId); if (status == UpdateWorkerStatus.LoginIncorrect) { logger.Error("Application sign in failed. Worker id is incorrect. Trying re-sign up"); if (!signUp()) { logger.Error("Application sign up failed"); return(false); } } else if (status != UpdateWorkerStatus.Ok) { logger.Error("Application sign in failed"); return(false); } if (!workerTasks.Init(Configuration)) { apiClient.SignOut(Configuration.WorkerId); return(false); } return(true); }
public void Passing_Negative_Boolean_False_To_Where_Should_Call_WhereTrue_Or_WhereFalse() { var query = new Query("Table").Where("Col", "!=", false); var engines = new[] { EngineCodes.SqlServer, }; var c = Compilers.Compile(engines, query); Assert.Equal("SELECT * FROM [Table] WHERE [Col] != cast(0 as bit)", c[EngineCodes.SqlServer].ToString()); }
public void Where_Nested() { var query = new Query("table") .Where(q => q.Where("a", 1).OrWhere("a", 2)); var engines = new[] { EngineCodes.SqlServer, }; var c = Compilers.Compile(engines, query); Assert.Equal("SELECT * FROM [table] WHERE ([a] = 1 OR [a] = 2)", c[EngineCodes.SqlServer].ToString()); }
public void OneFromPerEngine() { var query = new Query("generic") .ForSqlServer(q => q.From("dnu")) .ForSqlServer(q => q.From("mssql")); var engines = new[] { EngineCodes.SqlServer, EngineCodes.MySql, EngineCodes.PostgreSql }; var c = Compilers.Compile(engines, query); Assert.Equal(2, query.Clauses.OfType <AbstractFrom>().Count()); Assert.Equal("SELECT * FROM [mssql]", c[EngineCodes.SqlServer].RawSql); Assert.Equal("SELECT * FROM \"generic\"", c[EngineCodes.PostgreSql].RawSql); Assert.Equal("SELECT * FROM `generic`", c[EngineCodes.MySql].RawSql); }
public void Offset_Takes_Generic_If_Needed() { var query = new Query("mytable") .Limit(5) .Offset(10) .ForPostgreSql(q => q.Limit(20)); var engines = new[] { EngineCodes.MySql, EngineCodes.PostgreSql }; var c = Compilers.Compile(engines, query); Assert.Equal("SELECT * FROM `mytable` LIMIT 5 OFFSET 10", c[EngineCodes.MySql].ToString()); Assert.Equal("SELECT * FROM \"mytable\" LIMIT 20 OFFSET 10", c[EngineCodes.PostgreSql].ToString()); }
public void CompilerSpecificFromMixed() { var query = new Query() .ForSqlServer(q => q.From("mssql")) .ForPostgreSql(q => q.FromRaw("[pgsql]")) .ForMySql(q => q.From("mysql")); var engines = new[] { EngineCodes.SqlServer, EngineCodes.MySql, EngineCodes.PostgreSql }; var c = Compilers.Compile(engines, query); Assert.Equal("SELECT * FROM [mssql]", c[EngineCodes.SqlServer].RawSql); Assert.Equal("SELECT * FROM \"pgsql\"", c[EngineCodes.PostgreSql].RawSql); Assert.Equal("SELECT * FROM `mysql`", c[EngineCodes.MySql].RawSql); }