Пример #1
0
        //Load file
        private void bt_loadFile_Click(object sender, EventArgs e)
        {
            string        errorMessage;
            List <string> errorList;

            newCaseRunner = new CaseRunner("NU");
            if (newCaseRunner.LoadCase(tb_caseFilePath.Text, out errorMessage, out errorList))
            {
                if (errorList != null)
                {
                    foreach (string tempError in errorList)
                    {
                        MyControlHelper.setRichTextBoxContent(ref rtb_info, tempError, Color.Black, true);
                    }
                }
                newCaseRunner.RunnerCasePath = tb_caseFilePath.Text;
                MyControlHelper.setRichTextBoxContent(ref rtb_info, "加载完成请继续", Color.Blue, true);
                LoadFileData();
            }
            else
            {
                MyControlHelper.setRichTextBoxContent(ref rtb_info, errorMessage, Color.Red, true);
                newCaseRunner = null;
                FreezeAdd();
                MessageBox.Show(errorMessage);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var c = new CaseRunner();

            c.Run();
        }
Пример #3
0
        public void DelRunner(CaseRunner yourRunner)
        {
            this.Controls.Remove(yourRunner.runerProgressBar);
            this.Controls.Remove(yourRunner.runnerButton);
            this.Items.Remove(yourRunner.tagItem);

            yourRunner.tagItem.Tag = null;
            yourRunner.tagItem     = null;
        }
Пример #4
0
        public void AddRunner(CaseRunner yourRunner)
        {
            yourRunner.tagItem = new ListViewItem(new string[] { yourRunner.RunnerName, yourRunner.StartCellName, "", "", "", "", "", "Stop", "" });
            yourRunner.tagItem.UseItemStyleForSubItems = false;
            yourRunner.tagItem.Tag = yourRunner;

            this.Items.Add(yourRunner.tagItem);
            this.Controls.Add(yourRunner.runerProgressBar);
            this.Controls.Add(yourRunner.runnerButton);
        }
Пример #5
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_PAINT)
            {
                foreach (ListViewItem tempItem in this.Items)
                {
                    if (tempItem == null)
                    {
                        continue;
                    }
                    if (tempItem.Tag != null)
                    {
                        CaseRunner runnerTag = (CaseRunner)tempItem.Tag;
                        Control    nowC      = null;
                        //bar
                        ListViewItem.ListViewSubItem mySub = tempItem.SubItems[6];
                        Rectangle r = mySub.Bounds;
                        nowC = runnerTag.runerProgressBar;
                        if (r.Y > 10 && r.Y < this.ClientRectangle.Height)
                        {
                            nowC.Bounds  = new Rectangle(r.X + _cpadding, r.Y + _cpadding + 1, r.Width - (2 * _cpadding), r.Height - (2 * _cpadding + 2));
                            nowC.Visible = true;
                        }
                        else
                        {
                            nowC.Visible = false;
                        }

                        //but
                        mySub = tempItem.SubItems[8];
                        r     = mySub.Bounds;
                        nowC  = runnerTag.runnerButton;
                        if (r.Y > 10 && r.Y < this.ClientRectangle.Height)
                        {
                            nowC.Bounds  = new Rectangle(r.X + _cpadding, r.Y + _cpadding, r.Width - (2 * _cpadding), r.Height - (2 * _cpadding));
                            nowC.Visible = true;
                        }
                        else
                        {
                            nowC.Visible = false;
                        }
                    }
                }
            }
            base.WndProc(ref m);
        }
        public void ShouldWorkNormally()
        {
            // Arrange
            var     executor = A.Fake <IExecuteRules <ISimulationCase, IPerson> >();
            Guid    id1      = Guid.NewGuid();
            Guid    id2      = Guid.NewGuid();
            decimal val1     = 1.11m;
            decimal val2     = 2.22m;

            var p1 = A.Fake <IPerson>();

            p1.Id = id1;
            var p2 = A.Fake <IPerson>();

            p2.Id = id2;

            A.CallTo(() => executor.Execute(A <ISimulationCase> ._, A <IPerson> ._))
            .Returns(val1)
            .Once()
            .Then
            .Returns(val2);

            // Act
            var sut = new CaseRunner <ISimulationCase, IPerson>(executor);

            var simulationCase = A.Fake <ISimulationCase>();
            var persons        = new List <IPerson>()
            {
                p1, p2
            };

            var result = sut.Run(simulationCase, persons);

            // Assert
            Assert.Equal(val1, result.ResultSet[id1].Amount);
            Assert.Equal(val2, result.ResultSet[id2].Amount);
        }
Пример #7
0
 //Add User
 private void pictureBox_AddRunner_Click(object sender, EventArgs e)
 {
     if (newCaseRunner == null)
     {
         bt_loadFile_Click(null, null);
         if (newCaseRunner != null)
         {
             pictureBox_AddRunner_Click(null, null);
         }
     }
     else
     {
         int    tempIndex    = 0;
         int    tempCloneNum = 0;
         string tempName     = tb_runnerName.Text;
         while (myOwner.IsContainRunnerName(tempName))
         {
             tempName = tb_runnerName.Text + "_" + tempIndex;
             tempIndex++;
             if (tempIndex > 1000000)
             {
                 break;
             }
         }
         try
         {
             newCaseRunner.RunerActuator.ExecutiveThinkTime = int.Parse(tb_waitTime.Text);
         }
         catch
         {
             newCaseRunner.RunerActuator.ExecutiveThinkTime = 0;
             MyControlHelper.setRichTextBoxContent(ref rtb_info, "WaitTime Set Error", Color.Red, true);
         }
         try
         {
             tempCloneNum = int.Parse(tb_cloneNum.Text);
         }
         catch
         {
             tempCloneNum = 0;
             MyControlHelper.setRichTextBoxContent(ref rtb_info, "CloneNum Set Error", Color.Red, true);
         }
         newCaseRunner.RunnerName = tempName;
         try
         {
             newCaseRunner.StartCell = (CaseCell)cb_cList.SelectedValue;
         }
         catch
         {
             MyControlHelper.setRichTextBoxContent(ref rtb_info, "StartCell Set Error", Color.Red, true);
         }
         myOwner.AddRunner(newCaseRunner);
         MyControlHelper.setRichTextBoxContent(ref rtb_info, "新用户 " + tempName + "添加成功", Color.Red, true);
         if (tempCloneNum > 0)
         {
             if (tempCloneNum > 200)
             {
                 if (MessageBox.Show("您创建过多的克隆用户,可能需要较长的时间,是否继续?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     for (int i = 0; i < tempCloneNum; i++)
                     {
                         myOwner.AddRunner(newCaseRunner.Clone(tempName + "#" + i));
                         MyControlHelper.setRichTextBoxContent(ref rtb_info, "新克隆用户 " + tempName + "#" + i + " 添加成功", Color.Red, true);
                     }
                 }
             }
             else
             {
                 for (int i = 0; i < tempCloneNum; i++)
                 {
                     myOwner.AddRunner(newCaseRunner.Clone(tempName + "#" + i));
                     MyControlHelper.setRichTextBoxContent(ref rtb_info, "新克隆用户 " + tempName + "#" + i + " 添加成功", Color.Red, true);
                 }
             }
         }
         tb_cloneNum.Text = "0";
         newCaseRunner    = null;
     }
 }
Пример #8
0
 public RunnerSet(CaseRunner yourRunner)
 {
     InitializeComponent();
     nowRunner = yourRunner;
 }