コード例 #1
0
        public void RunLoop()
        {
            TestPlan testplan = new TestPlan();

            var  grandParent = new RepeatStep();
            uint loopCount   = 7;

            grandParent.Count  = loopCount;
            grandParent.Action = RepeatStep.RepeatStepAction.Fixed_Count;
            testplan.Steps.Add(grandParent);

            var parent = new WithEvents();

            grandParent.ChildTestSteps.Add(parent);

            testplan.BreakOffered += _testplan_TestStepPaused;

            _pausedDetectedCount   = 0;
            _startingDetectedCount = 0;

            testplan.Execute();

            //We will actually have loopCount + 1 starts.
            // We get a start for each of the loops around "withevents steps", plus one for the outer loop "FixedCountLoop" step
            Assert.AreEqual(loopCount + 1, _startingDetectedCount, "StartingDetectedCount");

            //Since fixed count loop does NOT have a pause, it will not count in the pause count.
            Assert.AreEqual(loopCount, _pausedDetectedCount, "PausedDetectedCount");
        }
コード例 #2
0
        public void RunHierarchical2()
        {
            TestPlan testplan = new TestPlan();

            var grandParent = new SequenceStep();

            testplan.Steps.Add(grandParent);

            var parent = new SequenceStep();

            grandParent.ChildTestSteps.Add(parent);

            var child1 = new WithEvents();

            parent.ChildTestSteps.Add(child1);

            var child2 = new WithEvents();

            parent.ChildTestSteps.Add(child2);

            testplan.BreakOffered += _testplan_TestStepPaused;

            _pausedDetectedCount   = 0;
            _startingDetectedCount = 0;

            testplan.Execute();

            // Since only two of the steps are with events, we get
            // _starting = total
            // _pausedCount = 2;
            var test = TotalEnabledStepsInTestPlan(testplan);

            Assert.IsTrue(_startingDetectedCount == TotalEnabledStepsInTestPlan(testplan));
            Assert.IsTrue(_pausedDetectedCount == 2);
        }
コード例 #3
0
        public void RunHierarchical()
        {
            TestPlan testplan = new TestPlan();

            var grandParent = new WithEvents();

            testplan.Steps.Add(grandParent);

            var parent = new WithEvents();

            grandParent.ChildTestSteps.Add(parent);

            var child1 = new WithEvents();

            parent.ChildTestSteps.Add(child1);

            var child2 = new WithEvents();

            parent.ChildTestSteps.Add(child2);

            testplan.BreakOffered += _testplan_TestStepPaused;

            _pausedDetectedCount   = 0;
            _startingDetectedCount = 0;

            testplan.Execute();

            // Since ALL the steps are of type WithEvents, we continue to get
            // a pausedcount = startingCount = totalcount.
            Assert.IsTrue(_startingDetectedCount == TotalEnabledStepsInTestPlan(testplan));
            Assert.IsTrue(_pausedDetectedCount == TotalEnabledStepsInTestPlan(testplan));
        }
コード例 #4
0
        private IQueryable <Applicant_QuickSearch.Projection> Filter(IQueryable <Applicant_QuickSearch.Projection> query)
        {
            query = query.Where(x => x.IsApplicant);

            if (Hired == ApplicantHiredFilter.Exclude)
            {
                query = query.Where(x => !x.IsHired);
            }
            else if (Hired == ApplicantHiredFilter.OnlyHired)
            {
                query = query.Where(x => x.IsHired);
            }

            Expression <Func <Applicant_QuickSearch.Projection, bool> > predicate = x =>
                                                                                    x.FullName1.StartsWith(Term) ||
                                                                                    x.FullName2.StartsWith(Term) ||
                                                                                    x.Companies.Any(y => y.StartsWith(Term)) ||
                                                                                    x.Skills.StartsWith(Term) ||
                                                                                    x.TechnicalSkills.Any(y => y.StartsWith(Term)) ||
                                                                                    x.AttachmentNames.Any(y => y.StartsWith(Term));

            if (SearchInAttachments)
            {
                predicate = predicate.Or(x => x.AttachmentContent.Any(y => y.StartsWith(Term)));
            }

            query = query.Where(predicate);

            foreach (var slug in WithEvents.EmptyIfNull())
            {
                query = query.Where(x => x.EventSlugs == slug);
            }

            if (Highlighted)
            {
                query = query.Where(x => x.IsHighlighted);
            }

            return(query);
        }
コード例 #5
0
        public void RunFlatTestplan()
        {
            TestPlan   testplan = new TestPlan();
            WithEvents step1    = new WithEvents();
            WithEvents step2    = new WithEvents();
            WithEvents step3    = new WithEvents();
            WithEvents step4    = new WithEvents();

            testplan.Steps.Add(step1);
            testplan.Steps.Add(step2);
            testplan.Steps.Add(step3);
            testplan.Steps.Add(step4);

            testplan.BreakOffered += _testplan_TestStepPaused;

            _pausedDetectedCount   = 0;
            _startingDetectedCount = 0;

            testplan.Execute();
            //Since the plan is flat, the starting and paused count is the same.
            Assert.IsTrue(_startingDetectedCount == TotalEnabledStepsInTestPlan(testplan));
            Assert.IsTrue(_pausedDetectedCount == TotalEnabledStepsInTestPlan(testplan));
        }
コード例 #6
0
        private IQueryable <Applicant_QuickSearch.Projection> Filter(IQueryable <Applicant_QuickSearch.Projection> query)
        {
            query = query.Where(x => x.IsApplicant);

            if (Hired == ApplicantHiredFilter.Exclude)
            {
                query = query.Where(x => !x.IsHired);
            }
            else if (Hired == ApplicantHiredFilter.OnlyHired)
            {
                query = query.Where(x => x.IsHired);
            }

            string firstPart  = "";
            string SecondPart = "";
            var    isSplit    = false;

            if (Term != null)
            {
                if (Term.Contains(","))
                {
                    firstPart  = Term.Split(',')[0].Replace(" ", string.Empty);
                    SecondPart = Term.Split(',')[1].Replace(" ", string.Empty);
                    isSplit    = true;
                }
                else if (Term.Contains(" "))
                {
                    firstPart  = Term.Split(' ')[0].Replace(" ", string.Empty);
                    SecondPart = Term.Split(' ')[1].Replace(" ", string.Empty);
                    isSplit    = true;
                }
            }

            Expression <Func <Applicant_QuickSearch.Projection, bool> > predicate = x =>
                                                                                    x.FullName1.StartsWith(Term) ||
                                                                                    x.FullName2.StartsWith(Term) ||
                                                                                    x.Companies.Any(y => y.StartsWith(Term)) ||
                                                                                    x.Skills.StartsWith(Term) ||
                                                                                    x.TechnicalSkills.Any(y => y.StartsWith(Term)) ||
                                                                                    x.AttachmentNames.Any(y => y.StartsWith(Term));

            if (isSplit)
            {
                predicate = predicate.Or(x => (x.FirstName.StartsWith(firstPart) && x.LastName.StartsWith(SecondPart)) ||
                                         (x.FirstName.StartsWith(SecondPart) && x.LastName.StartsWith(firstPart)));
            }

            if (SearchInAttachments)
            {
                predicate = predicate.Or(x => x.AttachmentContent.Any(y => y.StartsWith(Term)));
            }

            query = query.Where(predicate);

            foreach (var slug in WithEvents.EmptyIfNull())
            {
                query = query.Where(x => x.EventSlugs == slug);
            }

            if (Highlighted)
            {
                query = query.Where(x => x.IsHighlighted);
            }

            return(query);
        }
コード例 #7
0
        //************************************************************************************************/
        /// <summary> Function : InitializeController (). </summary>

        public void InitializeController(int comPort)
        {
            bool result = false;

            // Create and initialize the serial port for communicating with the RFID R/W.
            try
            {                   // Create the status message.
                _StatusMessage = "Creating the serial port....";

                // Create event handler struct first -- Seagate.AAS.IO.SerialPorts\SerialBase.cs.
                _SerialPortEvents = new WithEvents();
                // Create instance of serial port.
                _SerialPort = new SerialPort(_SerialPortEvents);

                // Configure the serial port settings (19200 bps, 8 data bits, 1 stop bit, no parity, no flow control).
                _SerialPort.Cnfg.BaudRate = LineSpeed.Baud_9600;
                _SerialPort.Cnfg.DataBits = ByteSize.Eight;
                _SerialPort.Cnfg.StopBits = StopBits.One;
                _SerialPort.Cnfg.Parity   = Parity.None;
                _SerialPort.Cnfg.FlowCtrl = Handshake.None;
                if (comPort < 10)
                {
                    _SerialPort.Cnfg.PortName = "COM" + comPort.ToString() + ":";
                }
                else                    // COM ports greater than 9 need to be formatted differently -- SS.
                {
                    _SerialPort.Cnfg.PortName = "\\\\.\\COM" + comPort.ToString();
                }

                // Based on the location of this RFID R/W, pick appropriate COM port.
                if (comPort > 0 && comPort < 20)
                {
                    this._COMPort = comPort;
                }
                else
                {
                    throw new ParselException("Invalid Com Port. Cannot Initialize Device");
                }

                // Only if NOT in hardware simulation mode, interface with hardware.
                if (!_HWSimulationMode)
                {                       // Update status message.
                    _StatusMessage = "Opening the COM port....";
                    // Open (initialize) the serial port with the configuration settings.
                    result = _SerialPort.Open(_COMPort);
                    // If initialization failed or port is 'really' not open (redundant check), throw a Parsel exception.
                    if (!result || !_SerialPort.IsOpen)
                    {
                        // Compose exception message with pre-defined error code in format 0x_____.
                        _ExceptionMessage += " Failed to Initialize RFID COM Port !!";
                        //_ExceptionCode = 1 ;
                        //_ExceptionMessage += " " + "Error Code : 0x" + _ExceptionCode.ToString ("Y").PadLeft (5, '0') + ".";
                        // Throw ParselException.
                        throw new ParselException(_ExceptionMessage);
                    }
                }
                // Update status message.
                _StatusMessage = "COM Port initialized.";
                _isInitialized = true;
            }
            // Catch any ParselExceptions thrown.  We probably just threw it. So just re-throw it.
            catch (ParselException exception)
            {
                _isInitialized = false;
                throw exception;
                //return;
            }
            // Catch any exceptions thrown.  Re-package it to ParselException object and throw exception.
            catch (Exception exception)
            {
                // Compose exception message with pre-defined error code in format 0x_____.
                _ExceptionMessage += " Failed to Initialize COM Port !!";
                _ExceptionMessage += exception.Message;
                _ExceptionMessage += " " + "Error Code : 0x" + _ExceptionCode.ToString("Y").PadLeft(5, '0') + ". ";
                _isInitialized     = false;
                // Throw ParselException.
                throw new ParselException(_ExceptionMessage);
            }
        }