public void ListsStructTestJSON() { //Arrange complexStructwithStrings s1 = new complexStructwithStrings() { a = "aaa", strings = new List <string>() { "aaa", "bbb", "ccc" }, b = "ggg" }; // Act NewPayLoad pl = new NewPayLoad("ll"); pl.AddJSONValue(s1); pl.ClosePackage(); string s123 = pl.BufferInfo; byte[] b = pl.GetPackage(); NewPayLoad pl2 = new NewPayLoad(b); complexStructwithStrings s2 = pl2.GetJSONValue <complexStructwithStrings>(); //Assert Assert.AreEqual(s1.a, s2.a); Assert.AreEqual(s2.strings.Count, s2.strings.Count); Assert.AreEqual(s2.strings[0], s2.strings[0]); Assert.AreEqual(s2.strings[1], s2.strings[1]); Assert.AreEqual(s2.strings[2], s2.strings[2]); Assert.AreEqual(s1.b, s2.b); }
static NewPayLoad GeneratePlatformActionPayload(IActPluginExecution ACT, Agent agent) { PlatformAction platformAction = ACT.GetAsPlatformAction(); if (ACT is ActUIElement actUi) { if (actUi.ElementLocateBy == eLocateBy.POMElement) { AddPOMLocators(ref platformAction, ref actUi, agent.ProjEnvironment, agent.BusinessFlow); } } // TODO: calculate VE ??!! NewPayLoad payload = new NewPayLoad("RunPlatformAction"); payload.AddJSONValue <PlatformAction>(platformAction); payload.ClosePackage(); // TODO: Process Valuefordriver!!!! return(payload); void AddPOMLocators(ref PlatformAction PlatformAction, ref ActUIElement UIElementAction, ProjEnvironment projEnvironment, BusinessFlow businessFlow) { Dictionary <string, string> Locators = new Dictionary <string, string>(); List <string> Frames = new List <string>(); string[] pOMandElementGUIDs = UIElementAction.ElementLocateValue.ToString().Split('_'); Guid selectedPOMGUID = new Guid(pOMandElementGUIDs[0]); ApplicationPOMModel currentPOM = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.GetRepositoryItemByGuid <ApplicationPOMModel>(selectedPOMGUID); if (currentPOM == null) { UIElementAction.ExInfo = string.Format("Failed to find the mapped element Page Objects Model with GUID '{0}'", selectedPOMGUID.ToString()); return; } Guid selectedPOMElementGUID = new Guid(pOMandElementGUIDs[1]); ElementInfo selectedPOMElement = (ElementInfo)currentPOM.MappedUIElements.Where(z => z.Guid == selectedPOMElementGUID).FirstOrDefault(); if (selectedPOMElement == null) { UIElementAction.ExInfo = string.Format("Failed to find the mapped element with GUID '{0}' inside the Page Objects Model", selectedPOMElement.ToString()); return; } else { List <NewPayLoad> switchframpayload = new List <NewPayLoad>(); if (selectedPOMElement.Path != null) { string[] spliter = new string[] { "," }; string[] iframesPathes = selectedPOMElement.Path.Split(spliter, StringSplitOptions.RemoveEmptyEntries); foreach (string iframePath in iframesPathes) { Frames.Add(iframePath); } } PlatformAction.InputParams.Add("Frames", Frames); //adding all locators from POM foreach (ElementLocator locator in selectedPOMElement.Locators.Where(x => x.Active == true).ToList()) { string locateValue; if (locator.IsAutoLearned) { locateValue = locator.LocateValue; } else { ElementLocator evaluatedLocator = locator.CreateInstance() as ElementLocator; GingerCore.ValueExpression VE = new GingerCore.ValueExpression(projEnvironment, businessFlow); locateValue = VE.Calculate(evaluatedLocator.LocateValue); } Locators.Add(locator.LocateBy.ToString(), locateValue); } if (PlatformAction.InputParams.ContainsKey("Locators")) { PlatformAction.InputParams["Locators"] = Locators; } else { PlatformAction.InputParams.Add("Locators", Locators); } } } }