public static bool SaveToModelFile(TestObjectNurse rootNurse, string filePath) { AppModel model = new AppModel(); foreach (TestObjectNurse nurseObject in rootNurse.Children) { ITestObject testObject = nurseObject.TestObject; model.Add(testObject); } try { WatcherEnable = false; AppModelManager.Save(model, filePath); EnsureWatcherCreated(filePath); AppEnvironment.CurrentModelPath = filePath; } finally { WatcherEnable = true; } return(true); }
public void AppModelManager_Save() { string filePath = "CalcAppModel.json"; string content = Utility.ReadFileContent(filePath); AppModel model = JsonUtil.DeserializeObject <AppModel>(content); AppModelManager.Save(model, "CalcAppModel2.json"); Assert.IsTrue(model.ModelFile.FilePath.EndsWith("CalcAppModel2.json")); //TODO validate the content }
public void AppModelManager_HierarchySave() { UIATestObject d1 = new UIATestObject() { NodeName = "rootWindow1", ControlName = "rootWindow1_controlName", ControlType = ControlType.Window, Description = "this is root window" }; UIATestObject d2 = new UIATestObject() { ControlName = "Panel1", ControlType = ControlType.TitleBar }; UIATestObject d3 = new UIATestObject() { ControlName = "Button", ControlType = ControlType.Tree }; /* { * {"name", "Button1"}, * {"index", "0"}, * {"helpText", "Some help Text"} * }; * * d3.AddProperty("name", "Button1"); * d3.AddProperty("index", "0"); * d3.AddProperty("helpText", "Some help Text"); */ UIATestObject d4 = new UIATestObject() { ControlType = ControlType.Text }; d4.AddProperty("id", "Text1"); /* * d4.SetItem<UIAPropertyItem>(new UIAPropertyItem() * { * Properties = new PropertyEntry() * { * {"id", "Text1"} * } * });*/ d1.AddChild(d2); d2.AddChild(d4); d2.AddChild(d3); AppModel model = new AppModel() { ProcessName = "calc.exe" }; model.Add(d1); AppModelManager.Save(model, "CalcAppModel3.json"); TestUtility.LaunchNotepad(Path.Combine(System.Environment.CurrentDirectory, "CalcAppModel3.json")); //TODO validate the content }