public void ModelFileHandler_SaveToModelFile() { TreeView treeView = new TreeView(); TestObjectNurse rootNurse = TestObjectNurse.FromTree(treeView); AppModel model = ModelFileHandler.LoadModelFile("UnitTestObjectModel1.json", rootNurse); TestObjectNurse nurseNode = (TestObjectNurse)rootNurse.FindRecursive(DescriptorKeys.NodeName, "Test Explorer"); string imageFilePath = AppEnvironment.GetModelResourceFilePath("TestObjectNurseTest.png"); CacheHandler.EnsureFileDirectoryExists(imageFilePath); Snapshot.CaptureImageToFile(new Rectangle(0, 0, 100, 200), imageFilePath); Assert.IsTrue(File.Exists(imageFilePath)); nurseNode.ImageFile = "TestObjectNurseTest.png"; //remove from root nurseNode.Remove(); AppEnvironment.DumpRecyclingBin(rootNurse); }
public void ModelFileHandler_LoadJsonData() { TreeView treeView = new TreeView(); TestObjectNurse rootNurse = TestObjectNurse.FromTree(treeView); ModelFileHandler.LoadModelFile("ObjectModel2.json", rootNurse); Assert.AreEqual(1, rootNurse.Children.Count, "only one root node"); Assert.AreEqual(1, rootNurse.Children.Count); TestObjectNurse parentNurse = rootNurse[0]; ITestObject testObject = parentNurse.TestObject; Assert.AreEqual(1, parentNurse.Children.Count); Assert.AreEqual("Window", testObject.ControlTypeString); TestObjectNurse childNurse = parentNurse[0]; ITestObject testObject2 = childNurse.TestObject; Assert.AreEqual("Document", testObject2.ControlTypeString, "only one child node"); }
public void ModelFileHandler_SaveJson() { TreeView treeView = new TreeView(); TestObjectNurse rootNurse = TestObjectNurse.FromTree(treeView); AppModel model = ModelFileHandler.LoadModelFile("UnitTestObjectModel1.json", rootNurse); ModelFileHandler.SaveToModelFile(rootNurse, "ObjectModel2.json"); }
public static String SaveNetwork(String name) { String content = ModelFileHandler.SaveModelToString(network); String fileId = GoogleDriveHandler.GetFileIdByName(name + "-nn"); if (fileId == null) { GoogleDriveHandler.UploadGoogleDocument(content, name + "-nn", "application/vnd.google-apps.file", "text/plain"); } else { GoogleDriveHandler.UploadGoogleDocument(content, name + "-nn", "application/vnd.google-apps.file", "text/plain", fileId); } return(String.Format("Successfully saved the network to {0}-nn", network.Name)); }
public static String LoadNetwork(String name) { if (isTraining) { return("You can't load a network when there already is one training."); } String networkId = GoogleDriveHandler.GetFileIdByName(name + "-nn"); if (String.IsNullOrEmpty(networkId)) { return(String.Format("No file found with the name {0}-nn.", name)); } String networkContent = GoogleDriveHandler.DownloadGoogleDocument(networkId, "text/plain", Encoding.UTF8); network = ModelFileHandler.LoadModelFromString(networkContent); network.Name = name; return("Network successfully loaded in."); }