public static Dictionary <string, string> getDevBuffers(DevRunRecord devRunRecord) { var devCollection = _db.GetCollection <DevRunRecord>("DevRunRecords"); var currDevRecord = devCollection.Find <DevRunRecord>(doc => doc.Id == devRunRecord.Id).FirstOrDefault(); return(currDevRecord.Buffers); }
public static async Task <string> InitDevRunRecord(DevRunRecord devRunRecord, string collection = "DevRunRecords") { var collect = _db.GetCollection <DevRunRecord>(collection); await collect.InsertOneAsync(devRunRecord); await HubConnectionFactory.SignalRConnection.InvokeAsync("DevRunningInfo", devRunRecord); return(devRunRecord.Id); }
public static async void AddInfoForDevRecord(DevRunRecord devRunRecord, string collection = "DevRunRecords") { var devCollection = _db.GetCollection <DevRunRecord>(collection); var currentDevRecord = devCollection.Find <DevRunRecord>(doc => doc.Id == devRunRecord.Id).FirstOrDefault(); currentDevRecord.Status = devRunRecord.Status; currentDevRecord.Log += "\n" + devRunRecord.Log; await devCollection.FindOneAndReplaceAsync <DevRunRecord>(doc => doc.Id == devRunRecord.Id, currentDevRecord); await HubConnectionFactory.SignalRConnection.InvokeAsync("DevRunningInfo", currentDevRecord); }
public static async void UpdatePassForDevRecord(DevRunRecord devRunRecord, string collection = "DevRunRecords") { var debugCollection = _db.GetCollection <DevRunRecord>(collection); var currDevRecord = debugCollection.Find <DevRunRecord>(doc => doc.Id == devRunRecord.Id).FirstOrDefault(); currDevRecord.Status = devRunRecord.Status; currDevRecord.EndAt = devRunRecord.EndAt; currDevRecord.ExecuteTime = devRunRecord.ExecuteTime; await debugCollection.FindOneAndReplaceAsync <DevRunRecord>(doc => doc.Id == devRunRecord.Id, currDevRecord); await HubConnectionFactory.SignalRConnection.InvokeAsync("DevRunningPass", currDevRecord); }
public async Task Setup() { string runType = TestContext.CurrentContext.Test.Properties.Get("RunType")?.ToString(); // Start HubConnection HubConnectionFactory.InitHubConnection(); await HubConnectionFactory.SignalRConnection.StartAsync(); switch (runType.ToUpper()) { case "DEV": DevRunRecord devRunRecord = new DevRunRecord() { TestCaseId = TestContext.CurrentContext.Test.Properties.Get("TestCaseId")?.ToString(), TestCaseName = TestContext.CurrentContext.Test.Properties.Get("TestCaseName")?.ToString(), TestCaseCodeName = TestContext.CurrentContext.Test.Properties.Get("TestCaseCodeName")?.ToString(), Description = TestContext.CurrentContext.Test.Properties.Get("Description")?.ToString(), Category = TestContext.CurrentContext.Test.Properties.Get("Category")?.ToString(), TestSuite = TestContext.CurrentContext.Test.Properties.Get("TestSuite")?.ToString(), TestGroup = TestContext.CurrentContext.Test.Properties.Get("TestGroup")?.ToString(), Team = TestContext.CurrentContext.Test.Properties.Get("Team")?.ToString(), StartAt = DateTime.UtcNow, RunMachine = Environment.MachineName, WorkItem = TestContext.CurrentContext.Test.Properties.Get("WorkItem")?.ToString(), Status = TestContext.CurrentContext.Result.Outcome.Status.ToString(), TestCaseType = TestContext.CurrentContext.Test.Properties.Get("TestCaseType")?.ToString(), }; //TestCase Info Console.WriteLine( $"---------------------{new string('-', devRunRecord.TestCaseId.Length)}--{new string('-', devRunRecord.TestCaseName.Length)}-------"); Console.WriteLine( $"------ Run TestCase: {devRunRecord.TestCaseId}: {devRunRecord.TestCaseName} ------"); Console.WriteLine( $"---------------------{new string('-', devRunRecord.TestCaseId.Length)}--{new string('-', devRunRecord.TestCaseName.Length)}-------"); Console.WriteLine(""); devRunRecord.Log = $"{DateTime.UtcNow} - [Setup]: -------- Setup --------"; devRunRecord.Log += "\nTest Case attributes:"; IList <string> lstPros = TestContext.CurrentContext.Test.Properties.Keys.ToList <string>(); foreach (var key in lstPros) { if (!key.Equals("WebDriver")) //WebDriver attribute is multiple, so need to get list of it before action { Console.WriteLine($"[{key}]: {TestContext.CurrentContext.Test.Properties.Get(key)}"); devRunRecord.Log += $"\n[{key}]: {TestContext.CurrentContext.Test.Properties.Get(key)}"; } else { IList lstDriver = (IList)TestContext.CurrentContext.Test.Properties["WebDriver"]; foreach (string driver in lstDriver) { Console.WriteLine($"[{key}]: {driver}"); devRunRecord.Log += $"\n[{key}]: {driver}"; } } } devRunRecord.Log += "\n"; _runId = await MongoDBHelpers.InitDevRunRecord(devRunRecord); TestExecutionContext.CurrentContext.CurrentTest.Properties.Set("Id", _runId); TestExecutionContext.CurrentContext.CurrentTest.Properties.Set("StartAt", devRunRecord.StartAt); await HubConnectionFactory.SignalRConnection.InvokeAsync("DevRunningInfo", devRunRecord); break; case "REGRESSION": RegressionRunRecord regRunRecord = new RegressionRunRecord() { RegressionTestId = TestContext.CurrentContext.Test.Properties.Get("RegressionTestId")?.ToString(), ErrorMessage = string.Empty, Log = string.Empty, ErrorScreenshot = string.Empty, Screenshot1 = string.Empty, Screenshot2 = string.Empty, StartAt = DateTime.UtcNow, ClientName = string.Empty, RunMachine = Environment.MachineName, Status = TestContext.CurrentContext.Result.Outcome.Status.ToString(), }; _runId = await MongoDBHelpers.InitRegRunRecord(regRunRecord); TestExecutionContext.CurrentContext.CurrentTest.Properties.Set("Id", _runId); TestExecutionContext.CurrentContext.CurrentTest.Properties.Set("StartAt", regRunRecord.StartAt); break; } }