public void AddOrUpdate(string property, object value, string subArea = null) { var propertKey = !string.IsNullOrEmpty(subArea) ? $"{subArea}:{property}" : property; try { _properties[propertKey] = value; } catch (Exception e) { _logger.Warning($"TelemetryDataCollector : AddOrUpdate : Failed to add {value} with key {propertKey} due to {e}"); } }
private TestRun ValidateAndPrepareForPublish(TestRun testRun) { if (testRun?.TestRunSummary == null) { _telemetry.AddAndAggregate(TelemetryConstants.RunSummaryNull, 1, TelemetryConstants.TestRunManagerEventArea); _logger.Error("TestRunManger : ValidateAndPrepareForPublish : TestRun or TestRunSummary is null."); return(null); } // TotalTests count should always be less than passed and failed test count combined if (testRun.TestRunSummary.TotalTests < testRun.TestRunSummary.TotalFailed + testRun.TestRunSummary.TotalPassed + testRun.TestRunSummary.TotalSkipped) { testRun.TestRunSummary.TotalTests = testRun.TestRunSummary.TotalFailed + testRun.TestRunSummary.TotalPassed + testRun.TestRunSummary.TotalSkipped; } if (testRun.TestRunSummary.TotalTests == 0) { _telemetry.AddAndAggregate(TelemetryConstants.TotalTestsZero, 1, TelemetryConstants.TestRunManagerEventArea); _logger.Error("TestRunManger : ValidateAndPrepareForPublish : No tests found."); return(null); } // Match the passed test count and clear the passed tests collection if mismatch occurs if (testRun.TestRunSummary.TotalPassed != testRun.PassedTests?.Count) { _telemetry.AddAndAggregate(TelemetryConstants.PassedCountMismatch, 1, TelemetryConstants.TestRunManagerEventArea); _logger.Warning("TestRunManger : ValidateAndPrepareForPublish : Passed test count does not match the Test summary."); testRun.PassedTests = new List <TestResult>(); } // Match the failed test count and clear the failed tests collection if mismatch occurs if (testRun.TestRunSummary.TotalFailed != testRun.FailedTests?.Count) { _telemetry.AddAndAggregate(TelemetryConstants.FailedCountMismatch, 1, TelemetryConstants.TestRunManagerEventArea); _logger.Warning("TestRunManger : ValidateAndPrepareForPublish : Failed test count does not match the Test summary."); testRun.FailedTests = new List <TestResult>(); } // Match the skipped test count and clear the failed tests collection if mismatch occurs if (testRun.TestRunSummary.TotalSkipped != testRun.SkippedTests?.Count) { _telemetry.AddAndAggregate(TelemetryConstants.SkippedCountMismatch, 1, TelemetryConstants.TestRunManagerEventArea); _logger.Warning("TestRunManger : ValidateAndPrepareForPublish : Skipped test count does not match the Test summary."); testRun.SkippedTests = new List <TestResult>(); } return(testRun); }