/// <summary> /// Runs a test for a single endpoint. /// </summary> private void DoTest(string endpoint, ref uint totalCount, ref uint failedCount) { uint thisTestTotalCount = 0; uint thisTestFailedCount = 0; bool success = true; Dictionary<string,TestBase> testers = new Dictionary<string,TestBase>(); DateTime globalStart = DateTime.UtcNow; TestBase lastTester = null; foreach (ServerTestCase testcase in m_testConfiguration.TestCases) { // ignore parent tests. if (String.IsNullOrEmpty(testcase.Parent)) { continue; } // get the test object for the group of tests. TestBase tester = null; if (!testers.TryGetValue(testcase.Parent, out tester)) { switch (testcase.Parent) { case "Session": { tester = new SessionTest( GetDefaultSession(), m_testConfiguration, Report, Report, lastTester); lastTester = tester; break; } case "Browse": { tester = new BrowseTest( GetDefaultSession(), m_testConfiguration, Report, Report, lastTester); lastTester = tester; break; } case "Read": { tester = new ReadTest( GetDefaultSession(), m_testConfiguration, Report, Report, lastTester); lastTester = tester; break; } case "Write": { tester = new WriteTest( GetDefaultSession(), m_testConfiguration, Report, Report, lastTester); lastTester = tester; break; } case "Call": { tester = new CallTest( GetDefaultSession(), m_testConfiguration, Report, Report, lastTester); lastTester = tester; break; } case "TranslatePath": { tester = new TranslatePathTest( GetDefaultSession(), m_testConfiguration, Report, Report, lastTester); lastTester = tester; break; } case "Subscribe": { tester = new SubscribeTest( GetDefaultSession(), m_testConfiguration, Report, Report, lastTester); lastTester = tester; break; } case "MonitoredItem": { tester = new MonitoredItemTest( GetDefaultSession(), m_testConfiguration, Report, Report, lastTester); lastTester = tester; break; } } // ignore unknown tests. if (tester == null) { continue; } testers.Add(testcase.Parent, tester); } try { m_testcase = testcase; if (!testcase.Enabled) { continue; } if (testcase.Breakpoint) { ReportBreakpoint(); } for (int ii = 1; ii <= m_testConfiguration.Iterations; ii++) { m_iterationCount = ii; m_totalIterationCount = (int)m_testConfiguration.Iterations; // check if test stopped. if (m_stopped) { break; } DateTime start = DateTime.UtcNow; thisTestTotalCount++; totalCount++; m_testCount++; Report("", null); ReportWithHeader( "{1}.{2} Test Started Run #{0} at {3:HH:mm:ss} for {4}", ii, testcase.Parent, testcase.Name, DateTime.Now, endpoint); if (!tester.Run(testcase, ii)) { success = false; thisTestFailedCount++; failedCount++; m_failedTestCount++; ReportWithHeader( "{1}.{2} Test Failed Run #{0} ({3}ms) at {4:HH:mm:ss} for {5}", ii, testcase.Parent, testcase.Name, GetElapsedTime(start), DateTime.Now, endpoint); continue; } ReportWithHeader( "{1}.{2} Test Success Run #{0} ({3}ms) at {4:HH:mm:ss} for {5}", ii, testcase.Parent, testcase.Name, GetElapsedTime(start), DateTime.Now, endpoint); } } finally { m_testcase = null; } } Report("", null); if (success) { if (m_stopped) { Report("WARNING: Test halted by User. Total Time = {0}ms.", GetElapsedTime(globalStart)); } else { Report("{0} tests completed successfully. Total Time = {1}ms.", thisTestTotalCount, GetElapsedTime(globalStart)); SavePerfData(m_defaultEndpoint, GetElapsedTime(globalStart)); } } else { Report("WARNING: {0} tests failed. {1} tests run. Total Time = {2}ms.", thisTestFailedCount, thisTestTotalCount, GetElapsedTime(globalStart)); } }