private void Set() { _config = IsInternal ? FileBroker.GetTextResource(ResourceOrigin) : FileBroker.GetNonUnityTextResource(ResourceOrigin); string[] rawKeys = _config.Split(new string[] { "\n", "\r" }, System.StringSplitOptions.RemoveEmptyEntries); _requiredConfigs = new List <KeyValuePair <string, string> >(); _customConfigs = new List <KeyValuePair <string, string> >(); _isRequiredSection = true; for (int i = 0; i < rawKeys.Length; i++) { if (rawKeys[i].StartsWith("**")) { if (i != 0) { _isRequiredSection = false; } continue; } string[] thisKey = rawKeys[i].Split('='); if (_isRequiredSection) { _requiredConfigs.Add(new KeyValuePair <string, string>(thisKey[0], thisKey[1])); } else { _customConfigs.Add(new KeyValuePair <string, string>(thisKey[0], thisKey[1])); } } }
public override void Set() { if (!AutomationMaster.AllMethodsInFramework.Any()) { AutomationMaster.SetAllMethodsInFramework(); } string rawFavoritesData = FileBroker.GetNonUnityTextResource(AutomationMaster.UnitTestMode ? FileResource.FavoritesUnit : FileResource.Favorites); List <string> favoritesEachRaw = rawFavoritesData.Split(AutomationMaster.DELIMITER).ToList(); FavoritesList = new List <KeyValuePair <string, List <KeyValuePair <bool, string> > > >(); for (int f = 0; f < favoritesEachRaw.Count; f++) { //Invalid data if (!favoritesEachRaw[f].Trim().Contains(internalDelimiter)) { continue; } List <string> pieces = favoritesEachRaw[f].Split(new string[] { internalDelimiter }, StringSplitOptions.None).ToList(); pieces = pieces.RemoveNullAndEmpty(); //Remove possible empties due to line breaks at end of file. string name = pieces.First(); List <KeyValuePair <bool, string> > tests = new List <KeyValuePair <bool, string> >(); for (int t = 1; t < pieces.Count; t++) { tests.Add(new KeyValuePair <bool, string>(pieces[t].EndsWith(classIndicator) ? true : false, pieces[t].EndsWith(classIndicator) ? pieces[t].Replace(classIndicator, string.Empty) : pieces[t])); } FavoritesList.Add(new KeyValuePair <string, List <KeyValuePair <bool, string> > >(name, tests)); } }
//Take raw file data and simply splice out substring that represents this Favorite's data. void DeleteFavorite() { string rawFavoritesData = FileBroker.GetNonUnityTextResource(AutomationMaster.UnitTestMode ? FileResource.FavoritesUnit : FileResource.Favorites); List <string> split = rawFavoritesData.Split(new string[] { string.Format("{0}{1}", AutomationMaster.DELIMITER, keyToDelete) }, StringSplitOptions.None).ToList(); StringBuilder newData = new StringBuilder(); if (split.Count > 1) { //The item to be deleted is the first Favorites list in the file, so there will not be a complete splice. newData.Append(split.First()); } split = split.Last().Split(AutomationMaster.DELIMITER).ToList(); for (int s = 1; s < split.Count; s++) { newData.Append(string.Format("{0}{1}", AutomationMaster.DELIMITER, split[s])); } FileBroker.SaveNonUnityTextResource(AutomationMaster.UnitTestMode ? FileResource.FavoritesUnit : FileResource.Favorites, newData.ToString(), true); Set(); Nexus.Self.Tests.Update_Data = true; }
public static void SaveBuddyHistory(string buddyName) { string saveName = buddyName.Replace(Arbiter.DEVICE_IDENTIFIER_PREFIX, string.Empty); string txt = FileBroker.GetNonUnityTextResource(FileResource.BuddyHistory); List <string> resultsRaw = txt.Split(new string[] { "\n" }, StringSplitOptions.None).ToList(); StringBuilder fileText = new StringBuilder(); if (!resultsRaw.Contains(saveName)) { resultsRaw.Add(saveName); } resultsRaw = resultsRaw.RemoveNullAndEmpty().Distinct(); for (int f = 0; f < resultsRaw.Count; f++) { fileText.AppendLine(saveName); } //Save updated results. FileBroker.SaveNonUnityTextResource(FileResource.BuddyHistory, fileText); }
public static void GetMostRecentsResults(string status = "", string plainText = "") { _testsMeta = new List <KeyValuePair <string, string[]> >(); //TODO: Remove tests from file that no longer are automation tests. bool skipCreate = string.IsNullOrEmpty(status); List <string> resultsRaw = new List <string>(); string txt = FileBroker.GetNonUnityTextResource(FileResource.LatestTestResults); resultsRaw = txt.Split(new string[] { "\n" }, StringSplitOptions.None).ToList(); if (resultsRaw.Count == 0 && !skipCreate) { fileText.AppendLine(plainText); } else { List <Type> currentClasses = AutomationMaster.GetAutomationClasses(); List <MethodInfo> currentMethods = new List <MethodInfo>(); currentClasses.ForEach(x => currentMethods.AddRange(x.GetMethods())); //Filter out tests that no longer exist, have been renamed, or are no longer marked as automation methods. currentMethods = currentMethods.FindAll(x => { Automation[] aut = (Automation[])Attribute.GetCustomAttributes(x, typeof(Automation)); return(aut != null && aut.Length > 0); }); for (int i = 0; i < resultsRaw.Count; i++) { if (!string.IsNullOrEmpty(resultsRaw[i])) { string[] row = resultsRaw[i].Split(AutomationMaster.DELIMITER); string testName = string.Empty; for (int r = 0; r < row.Length; r++) { string[] keyVal = row[r].Split(':'); if (keyVal[0] == "name") { testName = keyVal[1]; } } if (!string.IsNullOrEmpty(testName)) { //Ignore references to methods that are no longer valid automation methods for whatever reason. if (currentMethods.FindAll(x => x.Name == testName).Any()) { _testsMeta.Add(new KeyValuePair <string, string[]>(testName, row)); } } } } if (!skipCreate) { List <KeyValuePair <string, string[]> > matches = testsMeta.FindAll(x => x.Key == AutomationMaster.CurrentTestContext.TestName); if (!matches.Any()) { _testsMeta.Add(new KeyValuePair <string, string[]>(AutomationMaster.CurrentTestContext.TestName, plainText.Split(AutomationMaster.DELIMITER))); } else { _testsMeta.Remove(matches.First()); string[] newValues = new string[] { string.Format("status:{0}", status), string.Format("name:{0}", AutomationMaster.CurrentTestContext.TestName), string.Format("class:{0}", AutomationMaster.CurrentTestContext.ClassName), string.Format("test_categories:{0}", string.Join(",", AutomationMaster.CurrentTestContext.Categories.ToArray())), }; KeyValuePair <string, string[]> newInsert = new KeyValuePair <string, string[]>(AutomationMaster.CurrentTestContext.TestName, newValues); _testsMeta.Add(newInsert); } for (int f = 0; f < testsMeta.Count; f++) { fileText.AppendLine(string.Join(AutomationMaster.DELIMITER.ToString(), _testsMeta[f].Value)); } } } }
public static List <string> GetBuddyHistory() { string txt = FileBroker.GetNonUnityTextResource(FileResource.BuddyHistory); return(txt.Split(new string[] { "\n" }, StringSplitOptions.None).ToList().FindAll(x => x.Length > 0)); }
void OnEnable() { //If AutomationMaster has not been initialized, we may encounter errors using the Nexus window. Attaching the AutoConsole listener will allow for more helpful explanations. if (!AutomationMaster.Initialized) { Application.logMessageReceived -= AutoConsole.GetLog; //Detach if already attached. Application.logMessageReceived += AutoConsole.GetLog; //Attach handler to recieve incoming logs. } Application.logMessageReceived += ExceptionCallback; //Windows Architect = new DependencyArchitecture(); BuddyData = new BuddyData(); Console = new RunnerConsole(); CommandConsoleView = new CommandConsoleView(); Generator = new Generator(); Results = new RunResults(); Settings = new Settings(); Tests = new TestManifest(); Tools = new AdditionalTools(); Favorites = new Favorites(); Manifest = new Manifest(); Application.runInBackground = true; EditorApplication.playmodeStateChanged += PlaymodeStateChangeUpdates; Set(); m_ShowExtraFields = new AnimBool(true); m_ShowExtraFields.valueChanged.AddListener(Repaint); //Custom defined Tab order set from Additional Tools? List <string> tabOrderData = FileBroker.GetNonUnityTextResource(FileResource.NexusTabs).Split(AutomationMaster.DELIMITER).ToList().RemoveNullAndEmpty(); Dictionary <string, int> tabData = new Dictionary <string, int>(); for (int t = 0; t < tabOrderData.Count; t++) { string[] data = tabOrderData[t].Split('$'); tabData.Add(data.First(), data.Last().ToInt()); } TabDetails tab; //Test Manager Tab. int priorityId = 0; tabData.TryGetValue(Tests.GetType().Name, out priorityId); tab = new TabDetails(Tests, priorityId > 0 ? priorityId : 1); tab.Shortcut = new List <KeyCode> { KeyCode.Alpha1 }; tab.Tabs.Add(new SizedTab("⇊", TabSize.Small, 18)); tab.Tabs.Add(new SizedTab("Tests", TabSize.Medium)); tab.Tabs.Add(new SizedTab("Tests View", TabSize.Large)); AddWindowTab(tab); //Automation Console Window Tab. tabData.TryGetValue(Console.GetType().Name, out priorityId); tab = new TabDetails(Console, priorityId > 0 ? priorityId : 2); tab.Shortcut = new List <KeyCode> { KeyCode.Alpha2 }; tab.Tabs.Add(new SizedTab("✦", TabSize.Small, 18)); tab.Tabs.Add(new SizedTab("Console", TabSize.Medium)); tab.Tabs.Add(new SizedTab("Auto Console", TabSize.Large)); tab.OverrideScroll = true; AddWindowTab(tab); //Command Console View Tab. tabData.TryGetValue(CommandConsoleView.GetType().Name, out priorityId); tab = new TabDetails(CommandConsoleView, priorityId > 0 ? priorityId : 3); tab.Shortcut = new List <KeyCode> { KeyCode.Alpha3 }; tab.Tabs.Add(new SizedTab("☊", TabSize.Small, 22)); tab.Tabs.Add(new SizedTab("Commands", TabSize.Medium)); tab.Tabs.Add(new SizedTab("Commands View", TabSize.Large)); tab.OverrideScroll = true; AddWindowTab(tab); //Test Results Window Tab. tabData.TryGetValue(Results.GetType().Name, out priorityId); tab = new TabDetails(Results, priorityId > 0 ? priorityId : 4); tab.Shortcut = new List <KeyCode> { KeyCode.Alpha4 }; tab.Tabs.Add(new SizedTab("☑", TabSize.Small, TextGreen, 18)); tab.Tabs.Add(new SizedTab("Results", TabSize.Medium)); tab.Tabs.Add(new SizedTab("Tests Results", TabSize.Large)); AddWindowTab(tab); //Generator Window Tab. tabData.TryGetValue(Generator.GetType().Name, out priorityId); tab = new TabDetails(Generator, priorityId > 0 ? priorityId : 5); tab.Shortcut = new List <KeyCode> { KeyCode.Alpha5 }; tab.Tabs.Add(new SizedTab("●", TabSize.Small, Color.red, 26)); tab.Tabs.Add(new SizedTab("Generator", TabSize.Medium)); tab.Tabs.Add(new SizedTab("Generator", TabSize.Large)); tab.OverrideScroll = true; AddWindowTab(tab); //Architect Hidden Tab tabData.TryGetValue(Architect.GetType().Name, out priorityId); tab = new TabDetails(Architect, priorityId > 0 ? priorityId : 6); tab.Shortcut = new List <KeyCode> { KeyCode.Alpha6 }; tab.Tabs.Add(new SizedTab("❖", TabSize.Small, 18)); tab.Tabs.Add(new SizedTab("Dep Arc", TabSize.Medium)); tab.Tabs.Add(new SizedTab("Dependency", TabSize.Large)); AddWindowTab(tab); //Buddy Data Hidden Tab tabData.TryGetValue(BuddyData.GetType().Name, out priorityId); tab = new TabDetails(BuddyData, priorityId > 0 ? priorityId : 7); tab.Shortcut = new List <KeyCode> { KeyCode.Alpha7 }; tab.Tabs.Add(new SizedTab("❦", TabSize.Small, 18)); tab.Tabs.Add(new SizedTab("Buddy", TabSize.Medium)); tab.Tabs.Add(new SizedTab("Buddy Data", TabSize.Large)); AddWindowTab(tab); //Settings Hidden Tab tabData.TryGetValue(Settings.GetType().Name, out priorityId); tab = new TabDetails(Settings, priorityId > 0 ? priorityId : 8); tab.Shortcut = new List <KeyCode> { KeyCode.Alpha8 }; tab.Tabs.Add(new SizedTab("✎", TabSize.Small, 18)); tab.Tabs.Add(new SizedTab("Settings", TabSize.Medium)); tab.Tabs.Add(new SizedTab("Settings", TabSize.Large)); AddWindowTab(tab); //Other Tools Tab. tab = new TabDetails(Tools, 0); tab.Shortcut = new List <KeyCode> { KeyCode.Alpha9 }; tab.Tabs.Add(new SizedTab("✙", TabSize.Small, 18)); tab.Tabs.Add(new SizedTab("Tools", TabSize.Medium)); tab.Tabs.Add(new SizedTab("Other Tools", TabSize.Large)); AddWindowTab(tab); //Favorites Tab (Reusable Test Runs). tab = new TabDetails(Favorites, -1); AddWindowTab(tab); //Manifest Tab (Current Test Run). tab = new TabDetails(Manifest, -1); AddWindowTab(tab); AddPopup(ScriptableObject.CreateInstance <SimpleAlert>()); AddPopup(ScriptableObject.CreateInstance <RunTestsAlert>()); AddPopup(ScriptableObject.CreateInstance <RunClassesAlert>()); AddPopup(ScriptableObject.CreateInstance <ConsoleMessage>()); SelectTab(SwatWindows.Find(x => x.PriorityID == 1).Window); //Sets this as the default landing on load. }