public void TestCleanup() { ICallContext context = CallContextManagerInstance.CallContextOverride; ICallContext existingContext = context.ExistingCallContext(); Correlation.CorrelationEnd(); context.EndCallContext(); }
/// <summary> /// End a request /// </summary> private void EndRequest() { ICallContext context = CallContextManagerInstance.CallContextOverride; ICallContext existingContext = context.ExistingCallContext(); Correlation.CorrelationEnd(); context.EndCallContext(); }
public void SettingShouldLogDirectly_OnCurrentCorrelation_ShouldSetOnCorrelationOnly() { try { Correlation = new Correlation(new MemoryCorrelationHandler(), CallContextManagerInstance, MachineInformation); Assert.False(Correlation.ShouldLogDirectly, "ShouldLogDirectly should be set to false by default."); Correlation.CorrelationStart(null); Correlation.ShouldLogDirectly = true; Assert.True(Correlation.ShouldLogDirectly, "ShouldLogDirectly should be set to true."); Correlation.CorrelationEnd(); Assert.False(Correlation.ShouldLogDirectly, "ShouldLogDirectly should be set to false after correlation ended."); } finally { EndRequest(); } }
public void CorrelationEnd_MultipleCorrelations_ShouldUnwindHierarchy() { Correlation = new Correlation(new MemoryCorrelationHandler(), CallContextManagerInstance, MachineInformation); Guid[] correlations = new Guid[3]; for (int i = 0; i < 3; i++) { Correlation.CorrelationStart(null); correlations[i] = Correlation.CurrentCorrelation.VisibleId; } for (int i = 2; i >= 0; i--) { CorrelationData currentCorrelation = Correlation.CurrentCorrelation; Assert.Equal(correlations[i], currentCorrelation.VisibleId); Correlation.CorrelationEnd(); } Assert.Null(Correlation.CurrentCorrelation); CallContextManagerInstance.CallContextOverride.EndCallContext(); }