public void ConnectionsInheritFromCorrectFolder() { /** * Root * --Folder1 * ----Connection1 * ----Folder2 * ------Connection2 * ----Connection3 (inherits username) */ var folder1 = new ContainerInfo { Icon = "someicon1" }; var folder2 = new ContainerInfo { Icon = "someicon2" }; var connection1 = new ConnectionInfo(); var connection2 = new ConnectionInfo(); var connection3 = new ConnectionInfo { Inheritance = { Icon = true } }; _rootNode.AddChild(folder1); folder1.AddChildRange(new [] { connection1, folder2, connection3 }); folder2.AddChild(connection2); Assert.That(connection3.Icon, Is.EqualTo(folder1.Icon)); }
private RootNodeInfo CreateTreeStructure(Dictionary <ConnectionInfo, string> parentMapping) { var root = new RootNodeInfo(RootNodeType.Connection); foreach (var node in parentMapping) { // no parent mapped, add to root if (string.IsNullOrEmpty(node.Value)) { root.AddChild(node.Key); continue; } // search for parent in the list by GUID var parent = parentMapping .Keys .OfType <ContainerInfo>() .FirstOrDefault(info => info.ConstantID == node.Value); if (parent != null) { parent.AddChild(node.Key); } else { root.AddChild(node.Key); } } return(root); }
private ConnectionTreeModel SetupConnectionTreeModel() { /* * Root * |--- con0 * |--- folder1 * | L--- con1 * L--- folder2 * |--- con2 * L--- folder3 * |--- con3 * L--- con4 */ var connectionTreeModel = new ConnectionTreeModel(); var rootNode = new RootNodeInfo(RootNodeType.Connection); var folder1 = new ContainerInfo { Name = "folder1" }; var folder2 = new ContainerInfo { Name = "folder2" }; var folder3 = new ContainerInfo { Name = "folder3" }; var con0 = new ConnectionInfo { Name = "con0" }; var con1 = new ConnectionInfo { Name = "con1" }; var con2 = new ConnectionInfo { Name = "con2" }; var con3 = new ConnectionInfo { Name = "con3" }; var con4 = new ConnectionInfo { Name = "con4" }; rootNode.AddChild(folder1); rootNode.AddChild(folder2); rootNode.AddChild(con0); folder1.AddChild(con1); folder2.AddChild(con2); folder2.AddChild(folder3); folder3.AddChild(con3); folder3.AddChild(con4); connectionTreeModel.AddRootNode(rootNode); return connectionTreeModel; }
private ConnectionTreeModel SetupConnectionTreeModel() { /* * Root * |--- con0 * |--- folder1 * | L--- con1 * L--- folder2 * |--- con2 * L--- folder3 * |--- con3 * L--- con4 */ BuildTreeNodes(); var connectionTreeModel = new ConnectionTreeModel(); var rootNode = new RootNodeInfo(RootNodeType.Connection); rootNode.AddChild(_folder1); rootNode.AddChild(_folder2); rootNode.AddChild(_con0); _folder1.AddChild(_con1); _folder2.AddChild(_con2); _folder2.AddChild(_folder3); _folder3.AddChild(_con3); _folder3.AddChild(_con4); connectionTreeModel.AddRootNode(rootNode); return(connectionTreeModel); }
private RootNodeInfo BuildTree() { var root = new RootNodeInfo(RootNodeType.Connection); root.AddChild(new ConnectionInfo { PleaseConnect = true }); root.AddChild(new ConnectionInfo()); root.AddChild(new ConnectionInfo { PleaseConnect = true }); return(root); }
private ConnectionTreeModel SetupConnectionTreeModel() { /* * Root * |--- con0 * |--- folder1 * | L--- con1 * L--- folder2 * |--- con2 * L--- folder3 * |--- con3 * L--- con4 */ var connectionTreeModel = new ConnectionTreeModel(); var rootNode = new RootNodeInfo(RootNodeType.Connection); var folder1 = new ContainerInfo { Name = "folder1" }; var folder2 = new ContainerInfo { Name = "folder2" }; var folder3 = new ContainerInfo { Name = "folder3" }; var con0 = new ConnectionInfo { Name = "con0" }; var con1 = new ConnectionInfo { Name = "con1" }; var con2 = new ConnectionInfo { Name = "con2" }; var con3 = new ConnectionInfo { Name = "con3" }; var con4 = new ConnectionInfo { Name = "con4" }; rootNode.AddChild(folder1); rootNode.AddChild(folder2); rootNode.AddChild(con0); folder1.AddChild(con1); folder2.AddChild(con2); folder2.AddChild(folder3); folder3.AddChild(con3); folder3.AddChild(con4); connectionTreeModel.AddRootNode(rootNode); return(connectionTreeModel); }
public ConnectionTreeModel Deserialize() { var connectionTreeModel = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection); connectionTreeModel.AddRootNode(root); var connectionInfo = new ConnectionInfo(); foreach (var line in _fileContent) { var parts = line.Split(new[] { ':' }, 3); if (parts.Length < 3) { continue; } var key = parts[0]; var value = parts[2]; SetConnectionInfoParameter(connectionInfo, key, value); } root.AddChild(connectionInfo); return(connectionTreeModel); }
private ConnectionTreeModel CreateNodeHierarchy(List <ConnectionInfo> connectionList) { var connectionTreeModel = new ConnectionTreeModel(); var rootNode = new RootNodeInfo(RootNodeType.Connection) { ConstantID = "0" }; connectionTreeModel.AddRootNode(rootNode); foreach (DataRow row in _dataTable.Rows) { var id = (string)row["ConstantID"]; var connectionInfo = connectionList.First(node => node.ConstantID == id); var parentId = (string)row["ParentID"]; if (parentId == "0") { rootNode.AddChild(connectionInfo); } else { (connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(connectionInfo); } } return(connectionTreeModel); }
// .rdp file schema: https://technet.microsoft.com/en-us/library/ff393699(v=ws.10).aspx public ConnectionTreeModel Deserialize(string rdcFileContent) { var connectionTreeModel = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection); connectionTreeModel.AddRootNode(root); var connectionInfo = new ConnectionInfo(); foreach (var line in rdcFileContent.Split(Environment.NewLine.ToCharArray())) { var parts = line.Split(new[] { ':' }, 3); if (parts.Length < 3) { continue; } var key = parts[0].Trim(); var value = parts[2].Trim(); SetConnectionInfoParameter(connectionInfo, key, value); } root.AddChild(connectionInfo); return(connectionTreeModel); }
private ConnectionTreeModel CreateNodeHierarchy(List <ConnectionInfo> connectionList, DataTable dataTable) { var connectionTreeModel = new ConnectionTreeModel(); var rootNode = new RootNodeInfo(RootNodeType.Connection, "0") { PasswordString = _decryptionKey.ConvertToUnsecureString() }; connectionTreeModel.AddRootNode(rootNode); foreach (DataRow row in dataTable.Rows) { var id = (string)row["ConstantID"]; var connectionInfo = connectionList.First(node => node.ConstantID == id); var parentId = (string)row["ParentID"]; if (parentId == "0" || connectionList.All(node => node.ConstantID != parentId)) { rootNode.AddChild(connectionInfo); } else { (connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild( connectionInfo); } } return(connectionTreeModel); }
/// <summary> /// Builds a tree which looks like: /// Root /// |- folder1 /// | |- con1 /// |- con2 /// |- folder2 /// |- folder3 /// |- con3 /// </summary> /// <returns></returns> public ConnectionTreeModel Build() { var model = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection); var folder1 = new ContainerInfo { Name = "folder1", Username = "******", Domain = "domain1", Password = "******" }; var folder2 = new ContainerInfo { Name = "folder2", Username = "******", Domain = "domain2", Password = "******" }; var folder3 = new ContainerInfo { Name = "folder3", Inheritance = { Username = true, Domain = true, Password = true } }; var con1 = new ConnectionInfo { Name = "Con1", Username = "******", Domain = "domain1", Password = "******" }; var con2 = new ConnectionInfo { Name = "Con2", Username = "******", Domain = "domain2", Password = "******" }; var con3 = new ContainerInfo { Name = "con3", Inheritance = { Username = true, Domain = true, Password = true } }; root.AddChild(folder1); root.AddChild(con2); folder1.AddChild(con1); root.AddChild(folder2); folder2.AddChild(folder3); folder3.AddChild(con3); model.AddRootNode(root); return(model); }
private ConnectionTreeModel GenerateConnectionTreeModel() { var connectionTreeModel = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection) { IsExpanded = true }; var folder1 = new ContainerInfo { IsExpanded = true }; var folder2 = new ContainerInfo(); var con1 = new ConnectionInfo(); root.AddChild(folder1); folder1.AddChild(folder2); root.AddChild(con1); connectionTreeModel.AddRootNode(root); return(connectionTreeModel); }
public void InheritanceIsDisabledForNodesDirectlyUnderRootNode() { var rootNode = new RootNodeInfo(RootNodeType.Connection); var con1 = new ConnectionInfo { Inheritance = { Password = true } }; rootNode.AddChild(con1); Assert.That(con1.Inheritance.Password, Is.False); }
private ConnectionTreeModel CreateConnectionTreeModel() { var model = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection); var folder1 = new ContainerInfo { Name = "folder1", Username = "******", Domain = "domain1", Password = "******" }; var con1 = new ConnectionInfo { Name = "Con1", Username = "******", Domain = "domain1", Password = "******" }; var con2 = new ConnectionInfo { Name = "Con2", Username = "******", Domain = "domain2", Password = "******" }; root.AddChild(folder1); root.AddChild(con2); folder1.AddChild(con1); model.AddRootNode(root); return(model); }
private void CreateSimpleTreeModel() { /* * Root * |-- container1 * | L-- connection1 * L-- container2 * |-- container3 * | |-- connection3 * | |-- connection4 * | L-- connection5 * L-- connection2 */ _rootNode.AddChild(_container1); _rootNode.AddChild(_container2); _container1.AddChild(_connection1); _container2.AddChild(_container3); _container2.AddChild(_connection2); _container3.AddChild(_connection3); _container3.AddChild(_connection4); _container3.AddChild(_connection5); }
private XDocument CreateTestData(ConnectionInfo connectionInfo) { var rootNode = new RootNodeInfo(RootNodeType.Connection) { PasswordString = _key.ConvertToUnsecureString() }; rootNode.AddChild(connectionInfo); var nodeSerializer = new XmlConnectionNodeSerializer27(_cryptographyProvider, _key, new SaveFilter()); var serializer = new XmlConnectionsSerializer(_cryptographyProvider, nodeSerializer); var serializedData = serializer.Serialize(rootNode); return(XDocument.Parse(serializedData)); }
public void CannotDuplicatePuttyConnectionNode() { var connectionTreeModel = new ConnectionTreeModel(); var puttyRoot = new RootNodeInfo(RootNodeType.PuttySessions); var puttyConnection = new PuttySessionInfo(); puttyRoot.AddChild(puttyConnection); connectionTreeModel.AddRootNode(puttyRoot); _connectionTree.ConnectionTreeModel = connectionTreeModel; _connectionTree.ExpandAll(); _connectionTree.SelectedObject = puttyConnection; _connectionTree.DuplicateSelectedNode(); Assert.That(puttyRoot.Children, Has.One.Items); }
public void CanDuplicateConnectionNode() { var connectionTreeModel = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection); var con1 = new ConnectionInfo(); root.AddChild(con1); connectionTreeModel.AddRootNode(root); _connectionTree.ConnectionTreeModel = connectionTreeModel; _connectionTree.ExpandAll(); _connectionTree.SelectedObject = con1; _connectionTree.DuplicateSelectedNode(); Assert.That(root.Children, Has.Exactly(2).Items); }
public void SwitchFromInheritanceToConnectionPropertiesWhenClickingChildOfRootNode() { // connection with a normal parent container var root = new RootNodeInfo(RootNodeType.Connection); var containerWhoseParentIsRoot = new ContainerInfo(); var connection = new ConnectionInfo(); root.AddChild(containerWhoseParentIsRoot); containerWhoseParentIsRoot.AddChild(connection); _configWindow.SelectedTreeNode = connection; _configWindow.ShowInheritanceProperties(); _configWindow.SelectedTreeNode = containerWhoseParentIsRoot; Assert.That(_configWindow.PropertiesVisible, Is.True, () => "The property mode should switch from inheritance to connection properties " + "when clicking on a container whose parent is the root node."); }
private ConnectionTreeModel CreateNodeHierarchy(List<ConnectionInfo> connectionList) { var connectionTreeModel = new ConnectionTreeModel(); var rootNode = new RootNodeInfo(RootNodeType.Connection) {ConstantID = "0"}; connectionTreeModel.AddRootNode(rootNode); foreach (DataRow row in _dataTable.Rows) { var id = (string) row["ConstantID"]; var connectionInfo = connectionList.First(node => node.ConstantID == id); var parentId = (string) row["ParentID"]; if (parentId == "0") rootNode.AddChild(connectionInfo); else (connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(connectionInfo); } return connectionTreeModel; }
public void CopyHostnameDoesNotCopyAnythingIfNameOfSelectedContainerIsEmpty() { var connectionTreeModel = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection); var con1 = new ContainerInfo { Name = string.Empty }; root.AddChild(con1); connectionTreeModel.AddRootNode(root); _connectionTree.ConnectionTreeModel = connectionTreeModel; _connectionTree.ExpandAll(); _connectionTree.SelectedObject = con1; var clipboard = Substitute.For <IClipboard>(); _connectionTree.CopyHostnameSelectedNode(clipboard); clipboard.DidNotReceiveWithAnyArgs().SetText(""); }
public void CopyHostnameCopiesTheNodeNameOfTheSelectedContainer() { var connectionTreeModel = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection); var container = new ContainerInfo { Name = "MyFolder" }; root.AddChild(container); connectionTreeModel.AddRootNode(root); _connectionTree.ConnectionTreeModel = connectionTreeModel; _connectionTree.ExpandAll(); _connectionTree.SelectedObject = container; var clipboard = Substitute.For <IClipboard>(); _connectionTree.CopyHostnameSelectedNode(clipboard); clipboard.Received(1).SetText(container.Name); }
public void Setup() { _connectionTreeModel = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection); root.AddChild(new ConnectionInfo()); _connectionTreeModel.AddRootNode(root); _cryptographyProvider = new AeadCryptographyProvider(); var connectionNodeSerializer = new XmlConnectionNodeSerializer27( _cryptographyProvider, _connectionTreeModel.RootNodes.OfType <RootNodeInfo>().First().PasswordString.ConvertToSecureString(), new SaveFilter()); _serializer = new XmlConnectionsSerializer(_cryptographyProvider, connectionNodeSerializer); _xmlReaderSettings = new XmlReaderSettings { ValidationType = ValidationType.Schema, ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation | XmlSchemaValidationFlags.ReportValidationWarnings }; }
public ConnectionTreeModel Deserialize() { var connectionTreeModel = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection); connectionTreeModel.AddRootNode(root); var connectionInfo = new ConnectionInfo(); foreach (var line in _fileContent) { var parts = line.Split(new[] { ':' }, 3); if (parts.Length < 3) { continue; } var key = parts[0]; var value = parts[2]; SetConnectionInfoParameter(connectionInfo, key, value); } root.AddChild(connectionInfo); return connectionTreeModel; }
private ConnectionTreeModel SetupConnectionTreeModel() { /* * Root * |--- con0 * |--- folder1 * | L--- con1 * L--- folder2 * |--- con2 * L--- folder3 * |--- con3 * L--- con4 */ BuildTreeNodes(); var connectionTreeModel = new ConnectionTreeModel(); var rootNode = new RootNodeInfo(RootNodeType.Connection); rootNode.AddChild(_folder1); rootNode.AddChild(_folder2); rootNode.AddChild(_con0); _folder1.AddChild(_con1); _folder2.AddChild(_con2); _folder2.AddChild(_folder3); _folder3.AddChild(_con3); _folder3.AddChild(_con4); connectionTreeModel.AddRootNode(rootNode); return connectionTreeModel; }
private ConnectionTreeModel CreateConnectionTreeModel() { var model = new ConnectionTreeModel(); var root = new RootNodeInfo(RootNodeType.Connection); var folder1 = new ContainerInfo {Name = "folder1", Username = "******", Domain = "domain1", Password = "******"}; var con1 = new ConnectionInfo {Name = "Con1", Username = "******", Domain = "domain1", Password = "******" }; var con2 = new ConnectionInfo {Name = "Con2", Username = "******", Domain = "domain2", Password = "******" }; root.AddChild(folder1); root.AddChild(con2); folder1.AddChild(con1); model.AddRootNode(root); return model; }