Opc.Ua.ServerTest.MonitoredItemTest.Run C# (CSharp) Метод

Run() публичный Метод

Runs the test for all of the browse roots.
public Run ( ServerTestCase testcase, int iteration ) : bool
testcase ServerTestCase
iteration int
Результат bool
        public override bool Run(ServerTestCase testcase, int iteration)
        {
            try
            {
                LockServer();
                if (ReadOnlyTests)
                {
                    Log("WARNING: TestCase {0} skipped because client could not acquire a lock on the Server.", testcase.Name);
                    return true;
                }

                Iteration = iteration;

                // need fetch nodes used for the test if not already available.
                if (AvailableNodes.Count == 0)
                {
                    if (!GetNodesInHierarchy())
                    {
                        return false;
                    }
                }

                // get the writeable variables.
                if (WriteableVariables.Count == 0)
                {
                    if (!GetWriteableVariablesInHierarchy())
                    {
                        Log("WARNING: No writeable variables found.");
                        Log(WriteTest.g_WriteableVariableHelpText);
                        return true;
                    }
                }

                // do main test.
                NotificationEventHandler handler = new NotificationEventHandler(Session_Notification);

                try
                {
                    Session.Notification += handler;

                    bool result = true;

                    switch (testcase.Name)
                    {
                        case "Deadband":
                        {
                            if (!DoDeadbandTest(false))
                            {
                                Log("WARNING: Re-doing Deadband test to check if random timing glitches were the cause of failure.");
                                result = DoDeadbandTest(false);
                                break;
                            }

                            return true;
                        }

                        case "ModifyDeadband":
                        {
                            if (!DoDeadbandTest(true))
                            {
                                Log("WARNING: Re-doing ModifyDeadband test to check if random timing glitches were the cause of failure.");
                                result = DoDeadbandTest(true);
                                break;
                            }

                            return true;
                        }

                        case "QueueSize":
                        {
                            if (!DoQueueSizeTest(false))
                            {
                                Log("WARNING: Re-doing QueueSize test to check if random timing glitches were the cause of failure.");
                                result = DoQueueSizeTest(false);
                                break;
                            }

                            return true;
                        }

                        case "ModifyQueueSize":
                        {
                            if (!DoQueueSizeTest(true))
                            {
                                Log("WARNING: Re-doing ModifyQueueSize test to check if random timing glitches were the cause of failure.");
                                result = DoQueueSizeTest(true);
                                break;
                            }

                            return true;
                        }

                        case "ModifySamplingInterval":
                        {
                            if (!DoSamplingIntervalTest(true))
                            {
                                Log("WARNING: Re-doing ModifySamplingInterval test to check if random timing glitches were the cause of failure.");
                                result = DoSamplingIntervalTest(true);
                                break;
                            }

                            return true;
                        }

                        default:
                        {
                            if (!DoSamplingIntervalTest(true))
                            {
                                Log("WARNING: Re-doing SamplingInterval test to check if random timing glitches were the cause of failure.");
                                result = DoSamplingIntervalTest(false);
                                break;
                            }

                            return true;
                        }
                    }

                    if (!result && m_writeDelayed)
                    {
                        Log("WARNING: Test skipped because the system is likely overloaded and cannot process the requests fast enough.");
                        result = true;
                    }

                    return result;
                }
                finally
                {
                    Session.Notification -= handler;
                }
            }
            finally
            {
                UnlockServer();
            }
        }        
        #endregion