Exemple #1
0
        public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues()
        {
            DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
            var inheritanceInstance = new ConnectionInfoInheritance(new object());

            Assert.That(inheritanceInstance.EverythingInherited, Is.True);
        }
Exemple #2
0
        private static void CloneConnectionNode(TreeNode oldTreeNode, TreeNode parentNode)
        {
            ConnectionInfo oldConnectionInfo = (ConnectionInfo)oldTreeNode.Tag;

            ConnectionInfo            newConnectionInfo = oldConnectionInfo.Copy();
            ConnectionInfoInheritance newInheritance    = oldConnectionInfo.Inheritance.Copy();

            newInheritance.Parent         = newConnectionInfo;
            newConnectionInfo.Inheritance = newInheritance;

            Runtime.ConnectionList.Add(newConnectionInfo);

            TreeNode newTreeNode = new TreeNode(newConnectionInfo.Name);

            newTreeNode.Tag                = newConnectionInfo;
            newTreeNode.ImageIndex         = (int)TreeImageType.ConnectionClosed;
            newTreeNode.SelectedImageIndex = (int)TreeImageType.ConnectionClosed;

            newConnectionInfo.TreeNode = newTreeNode;

            if (parentNode == null)
            {
                oldTreeNode.Parent.Nodes.Insert(oldTreeNode.Index + 1, newTreeNode);
                ConnectionTree.SelectedNode = newTreeNode;
            }
            else
            {
                ContainerInfo parentContainerInfo = parentNode.Tag as ContainerInfo;
                if (parentContainerInfo != null)
                {
                    newConnectionInfo.Parent = parentContainerInfo;
                }
                parentNode.Nodes.Add(newTreeNode);
            }
        }
Exemple #3
0
        public void NewInheritanceInstancesCreatedWithDefaultInheritanceValues()
        {
            DefaultConnectionInheritance.Instance.Domain = true;
            var inheritanceInstance = new ConnectionInfoInheritance(new object());

            Assert.That(inheritanceInstance.Domain, Is.True);
        }
Exemple #4
0
        public void SavingDefaultInheritanceExportsAllProperties()
        {
            var inheritanceDestination = new ConnectionInfoInheritance(new object(), true);

            DefaultConnectionInheritance.Instance.AutomaticResize = true;
            DefaultConnectionInheritance.Instance.SaveTo(inheritanceDestination);
            Assert.That(inheritanceDestination.AutomaticResize, Is.True);
        }
Exemple #5
0
        public void LoadingDefaultInheritanceUpdatesAllProperties()
        {
            var inheritanceSource = new ConnectionInfoInheritance(new object(), true);

            inheritanceSource.TurnOnInheritanceCompletely();
            DefaultConnectionInheritance.Instance.LoadFrom(inheritanceSource);
            Assert.That(DefaultConnectionInheritance.Instance.EverythingInherited, Is.True);
        }
        public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues(PropertyInfo property)
        {
            DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
            var inheritanceInstance = new ConnectionInfoInheritance(new ConnectionInfo());

            var valueInDestination = property.GetValue(inheritanceInstance);
            var valueInSource      = property.GetValue(DefaultConnectionInheritance.Instance);

            Assert.That(valueInDestination, Is.EqualTo(valueInSource));
        }
        internal static ConnectionInfoInheritance GetRandomizedInheritance(ConnectionInfo parent)
        {
            var inheritance = new ConnectionInfoInheritance(parent, true);

            foreach (var property in inheritance.GetProperties())
            {
                property.SetValue(inheritance, Randomizer.RandomBool());
            }
            return(inheritance);
        }
Exemple #8
0
        private static void ImportComputers(string ldapPath, TreeNode parentTreeNode)
        {
            try
            {
                const string ldapFilter = "(objectClass=computer)";

                var ldapSearcher = new DirectorySearcher();
                var ldapResults  = default(SearchResultCollection);
                var ldapResult   = default(SearchResult);

                ldapSearcher.SearchRoot = new DirectoryEntry(ldapPath);
                ldapSearcher.PropertiesToLoad.AddRange(new[] { "securityEquals", "cn" });
                ldapSearcher.Filter      = ldapFilter;
                ldapSearcher.SearchScope = SearchScope.OneLevel;

                ldapResults = ldapSearcher.FindAll();

                foreach (SearchResult tempLoopVar_ldapResult in ldapResults)
                {
                    ldapResult = tempLoopVar_ldapResult;
                    var with_2      = ldapResult.GetDirectoryEntry();
                    var displayName = Convert.ToString(with_2.Properties["cn"].Value);
                    var description = Convert.ToString(with_2.Properties["Description"].Value);
                    var hostName    = Convert.ToString(with_2.Properties["dNSHostName"].Value);

                    var treeNode = ConnectionTreeNode.AddNode(TreeNodeType.Connection, displayName);

                    var connectionInfo  = new ConnectionInfo();
                    var inheritanceInfo = new ConnectionInfoInheritance(connectionInfo);
                    inheritanceInfo.TurnOnInheritanceCompletely();
                    inheritanceInfo.Description = false;
                    if (parentTreeNode.Tag is ContainerInfo)
                    {
                        connectionInfo.Parent = (ContainerInfo)parentTreeNode.Tag;
                    }
                    connectionInfo.Inheritance = inheritanceInfo;
                    connectionInfo.Name        = displayName;
                    connectionInfo.Hostname    = hostName;
                    connectionInfo.Description = description;
                    connectionInfo.TreeNode    = treeNode;
                    treeNode.Name = displayName;
                    treeNode.Tag  = connectionInfo;                    //set the nodes tag to the conI
                    //add connection to connections
                    Runtime.ConnectionList.Add(connectionInfo);

                    parentTreeNode.Nodes.Add(treeNode);
                }
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.ImportComputers() failed.", ex, logOnly: true);
            }
        }
        public void SavingDefaultInheritanceExportsAllProperties(PropertyInfo property)
        {
            var saveTarget = new ConnectionInfoInheritance(new ConnectionInfo(), true);

            saveTarget.TurnOffInheritanceCompletely();
            DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();

            DefaultConnectionInheritance.Instance.SaveTo(saveTarget);

            var valueInDestination = property.GetValue(saveTarget);
            var valueInSource      = property.GetValue(DefaultConnectionInheritance.Instance);

            Assert.That(valueInDestination, Is.EqualTo(valueInSource));
        }
        public void LoadingDefaultInheritanceUpdatesAllProperties(PropertyInfo property)
        {
            var inheritanceSource = new ConnectionInfoInheritance(new ConnectionInfo(), true);

            inheritanceSource.TurnOnInheritanceCompletely();
            DefaultConnectionInheritance.Instance.TurnOffInheritanceCompletely();

            DefaultConnectionInheritance.Instance.LoadFrom(inheritanceSource);

            var valueInDestination = property.GetValue(DefaultConnectionInheritance.Instance);
            var valueInSource      = property.GetValue(inheritanceSource);

            Assert.That(valueInDestination, Is.EqualTo(valueInSource));
        }
Exemple #11
0
 public void Teardown()
 {
     _connectionInfo = null;
     _inheritance    = null;
 }
Exemple #12
0
 public void Setup()
 {
     _connectionInfo = new ConnectionInfo();
     _inheritance    = new ConnectionInfoInheritance(_connectionInfo);
 }