Esempio n. 1
0
        public void AddCommand(string commandType)
        {
            CommandBase cb = CommandBase.CreateCommand(_testSuite, commandType);

            var commandNode = new TreeNode(cb.CommandName)
            {
                Tag = cb
            };

            var commandSet = treeTest.SelectedNode.Tag as CommandSet;

            if (commandSet != null)
            {
                CommandSet cs = commandSet;
                cs.Commands.Add(cb);
                treeTest.SelectedNode.Nodes.Add(commandNode);
            }
            else
            {
                var ssisAssert = treeTest.SelectedNode.Tag as SsisAssert;
                if (ssisAssert != null)
                {
                    if (ssisAssert.Command != null)
                    {
                        throw new ArgumentException("There can only be one Command for an Assert. Please delete the existing Command before adding a new one.");
                    }

                    ssisAssert.Command = cb;
                    treeTest.SelectedNode.Nodes.Add(commandNode);
                }
            }
            commandNode.EnsureVisible();
            treeTest.SelectedNode = commandNode;
        }
Esempio n. 2
0
        /// <summary>
        /// 通信処理本体
        /// </summary>
        /// <param name="stream">送受信ストリーム</param>
        private void communicationMain(NetworkStream stream)
        {
            while (true)
            {
                Thread.Sleep(10);

                if (m_StopRequest == null)
                {
                    break;
                }

                if (m_StopRequest.WaitOne(10) == true)
                {
                    m_TcpClient.Close();
                    m_TcpClient.Dispose();
                    break;
                }

                if (m_RequestQueue.Count <= 0)
                {
                    continue;
                }

                CommandBase command = m_RequestQueue.Dequeue();

                int    expectedSize = 0;
                byte[] sendData     = command.CreateCommand(out expectedSize);
                byte[] response     = new byte[expectedSize];

                try
                {
                    stream.Write(sendData, 0, sendData.Length);
                }
                catch (Exception)
                {
                    goto FINISH;
                }

                try
                {
                    int index  = 0;
                    int remain = expectedSize;
                    while (0 < remain)
                    {
                        int once = stream.Read(response, index, remain);
                        index  += once;
                        remain -= once;
                    }
                }
                catch (Exception)
                {
                    goto FINISH;
                }

                command.Analyze(response);
            }

FINISH:
            return;
        }