示例#1
0
        protected void btnTestSave_Click(object sender, EventArgs e)
        {
            string  name   = txtTestName.Text;
            int     typeId = Convert.ToInt32(ddlTestType.SelectedItem.Value);
            decimal Number;
            bool    IsExistsNumber = decimal.TryParse(txtTestFee.Text, out Number);

            if (IsExistsNumber)
            {
                if (Number >= 0)
                {
                    decimal testFee = Number;

                    Tests test = new Tests(name, testFee, typeId);
                    try
                    {
                        int rowAffected = testManager.AddTest(test);

                        if (rowAffected > 0)
                        {
                            lblMessage.Text      = "Data saved";
                            lblMessage.ForeColor = System.Drawing.Color.Green;
                            ShowTest();
                        }
                    }
                    catch (Exception exception)
                    {
                        lblMessage.Text      = exception.Message;
                        lblMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
                else
                {
                    lblMessage.Text      = "Fee cannot be negative ";
                    lblMessage.ForeColor = System.Drawing.Color.Red;
                }
            }
            else
            {
                lblMessage.Text      = "Fee must be numeric";
                lblMessage.ForeColor = System.Drawing.Color.Red;
            }

            Clear();
        }
        protected void btnTestSave_Click(object sender, EventArgs e)
        {
            decimal Number;
            bool    IsExistsNumber = decimal.TryParse(txtTestFee.Text, out Number);

            if (IsExistsNumber)
            {
                if (Number >= 0)
                {
                    try
                    {
                        Label1.Visible       = false;
                        lblNumberMsg.Visible = false;
                        decimal testFee = Number;
                        string  name    = txtTestName.Text;
                        int     typeId  = Convert.ToInt32(ddlTestType.SelectedItem.Value);

                        Tests test        = new Tests(name, testFee, typeId);
                        int   rowAffected = testManager.AddTest(test);

                        if (rowAffected > 0)
                        {
                            ShowTest();
                        }
                    }
                    catch (Exception exception)
                    {
                        Label1.Visible   = true;
                        Label1.Text      = exception.Message;
                        Label1.ForeColor = System.Drawing.Color.Red;
                    }
                }
                else
                {
                    lblNumberMsg.Text      = "Number must be greater than or equal 0";
                    lblNumberMsg.ForeColor = System.Drawing.Color.Red;
                }
            }


            Clear();
        }
示例#3
0
        private bool AddTest(TestManager parent, TestConfig testConfig)
        {
            TestBase test = null;
              var timeInterval = GetFromTemplate(testConfig.TimeIntervalTemplate, _id);
              int ti = 0;

              Int32.TryParse(timeInterval, out ti);
              testConfig.TimeInterval = ti;

              switch (testConfig.GetType().Name)
              {
            case "LoopConfig":
              var cfgLoop = testConfig as LoopConfig;
              test = new TestManager(testConfig.Name) { StartCondition = cfgLoop.StartCondition, Delay = cfgLoop.TimeInterval, Iterations = cfgLoop.Iterations, StopOnError = cfgLoop.StopOnError, NotifyWhenIterationFinished = cfgLoop.NotifyWhenIterationFinished, StatisticsGatherer = ClientStatisticsGatherer };
              cfgLoop.Tests.ForEach(d=>AddTest(test as TestManager, d));
            break;

            case "LoginTestConfig":
              var cfgLogin = testConfig as LoginTestConfig;
              _login = GetFromTemplate(cfgLogin.LoginTemplate, _id);
              TestStaticDataMng.Register(_login);
              var passwd = CreatePassword(_login);
              test = new LoginTest(_login, passwd) { StartCondition = cfgLogin.StartCondition, Delay = cfgLogin.TimeInterval, StatisticsGatherer = ClientStatisticsGatherer };
            break;

            case "TotalCardListTestConfig":
              var cfgTotalCardListTest = testConfig as TotalCardListTestConfig;
              test = new TotalCardListTest(cfgTotalCardListTest.NumItemsOnPage) { StartCondition = cfgTotalCardListTest.StartCondition,Delay = cfgTotalCardListTest.TimeInterval, StatisticsGatherer = ClientStatisticsGatherer };
            break;

            case "RelevantCardListTestConfig":
              var cfgRelevantCardListTest = testConfig as RelevantCardListTestConfig;
              test = new RelevantCardListTest(cfgRelevantCardListTest.NumItemsOnPage) { StartCondition = cfgRelevantCardListTest.StartCondition,Delay = cfgRelevantCardListTest.TimeInterval, StatisticsGatherer = ClientStatisticsGatherer };
            break;

            case "IncidentTypeChoiceTestConfig":
              var cfgIncidentTypeChoice = testConfig as IncidentTypeChoiceTestConfig;
              test = new IncidentTypeChoiceTest(cfgIncidentTypeChoice.IncidentTypeName, cfgIncidentTypeChoice.NumItemsOnPage) { StartCondition = cfgIncidentTypeChoice.StartCondition, Delay = cfgIncidentTypeChoice.TimeInterval, StatisticsGatherer = ClientStatisticsGatherer };
            break;

            case "LogoutTestConfig":
              var cfgLogout = testConfig as LogoutTestConfig;
              test = new LogoutTest { StartCondition = cfgLogout.StartCondition, Delay = cfgLogout.TimeInterval, StatisticsGatherer = ClientStatisticsGatherer };
            break;

            case "CardListTestConfig":
              var cfgCardList = testConfig as CardListTestConfig;
              test = new CardListTest(cfgCardList.NumberOfPageChanging, ClientStatisticsGatherer) { StartCondition = cfgCardList.StartCondition, Delay = cfgCardList.TimeInterval };
            break;

            case "CardTestConfig":
              var cfgCard = testConfig as CardTestConfig;
              test = new CardTest(ClientStatisticsGatherer) { StartCondition = cfgCard.StartCondition, Delay = cfgCard.TimeInterval,  };
              cfgCard.Tests.ForEach(d => AddTest(test as TestManager, d));
            break;

            case "CardSaveTestConfig":
              var cfgSave = testConfig as CardSaveTestConfig;
              if (!(parent is CardTest)) return false;
              test = new SaveCard(parent as CardTest, cfgSave) { StartCondition = cfgSave.StartCondition, Delay = cfgSave.TimeInterval, StatisticsGatherer = ClientStatisticsGatherer };
            break;

            case "CardCloseTestConfig":
              var cfgClose = testConfig as CardCloseTestConfig;
              if (!(parent is CardTest)) return false;
              test = new CloseCard(cfgClose.CallsToCard, parent as CardTest ) { StartCondition = cfgClose.StartCondition, Delay = cfgClose.TimeInterval, StatisticsGatherer = ClientStatisticsGatherer };
              break;

            case "WaitCallConfig":
              var wcCfg = testConfig as WaitCallConfig;
              test = new WaitCall(wcCfg.CallCommitCondition, wcCfg.CommitPause, wcCfg.AcceptCalls, wcCfg.RejectCalls, wcCfg.NoAnswer, Data) { StartCondition = wcCfg.StartCondition, Delay = wcCfg.TimeInterval, StatisticsGatherer = ClientStatisticsGatherer };
            break;
              }

              if (parent == null)
              {
            _testMng = test as TestManager;
              }
              else
              {
            parent.AddTest(test);
              }

              return true;
        }