Exemplo n.º 1
0
        private void TestConnectionGenerator(
            MapNodeInColumn[] fromNodes,
            MapNodeInColumn[] toNodes,
            List <Tuple <int, int>[]> expectedPossibilities)
        {
            var expected = new List <IEnumerable <Connection> >();

            foreach (var ep in expectedPossibilities)
            {
                var connections = new List <Connection>();
                foreach (var c in ep)
                {
                    connections.Add(new Connection
                    {
                        From = fromNodes.First(n => n.NodeId == c.Item1.ToString()),
                        To   = toNodes.First(n => n.NodeId == c.Item2.ToString()),
                    });
                }
                expected.Add(connections);
            }

            var solutions = new ConnectionGenerator()
                            .GeneratePossibilities(fromNodes, toNodes);

            solutions.ToFormattedString().ShouldBe(expected.ToFormattedString());
        }
        public void ValidateTestCases(
            int testCase,
            MapNodeInColumn[] fromNodes,
            MapNodeInColumn[] toNodes,
            List <IEnumerable <Connection> > expected)
        {
            var solutions = new ConnectionGenerator()
                            .GeneratePossibilities(fromNodes, toNodes);

            solutions.ToFormattedString().ShouldBe(expected.ToFormattedString());
        }
        public void BasicTwoNodes()
        {
            var f0 = 0.MakeNode();
            var t0 = 0.MakeNode();
            var fromNodes
                = new[] { f0 };
            var toNodes
                = new[] { t0 };
            var expected = new List <IEnumerable <Connection> > {
                new List <Connection> {
                    f0.MakeConnection(t0)
                }
            };

            var solutions = new ConnectionGenerator()
                            .GeneratePossibilities(fromNodes, toNodes);

            solutions.ToFormattedString().ShouldBe(expected.ToFormattedString());
        }
Exemplo n.º 4
0
            protected override void ProcessRecord()
            {
                ConnectionGenerator generator = new ConnectionGenerator(UseSSL, Credential, Port);
                Runspace R = generator.Generate(ComputerName, Timeout);
                R.Open();
                PowerShell shell = PowerShell.Create();
                shell.Runspace = R;
                string script = Host.UI.ReadLine();
                while (!script.Equals("exit", StringComparison.CurrentCultureIgnoreCase))
                {
                    shell.Commands.Clear();
                    shell.AddScript(script);
                    Collection<PSObject> ret = shell.Invoke();
                    if (ret != null)
                        WriteObject(ret, true);
                    Host.UI.WriteLine();
                    Host.UI.Write(ComputerName + "> ");
                    script = Host.UI.ReadLine();
                }

                try
                {
                    shell.Dispose();
                    R.Close();
                }
                catch (Exception)
                { }
            }
Exemplo n.º 5
0
            protected override void ProcessRecord()
            {
                ConnectionGenerator generator = new ConnectionGenerator(UseSSL, Credential, Port);
                foreach (string comp in ComputerName)
                {
                    Collection<PSObject> result = Exec(generator.Generate(comp, Timeout), this.Command);
                    RemoteOutput O = new RemoteOutput(comp);
                    if (result != null)
                        O.Output.AddRange(result);
                    else
                        O.Output = null;

                    WriteObject(O);
                }
            }