コード例 #1
0
        public void CorrelationClear_ShouldClearAllCorrelations()
        {
            try
            {
                Correlation = new Correlation(new MemoryCorrelationHandler(), CallContextManagerInstance, MachineInformation);
                Correlation.CorrelationStart(null);

                CorrelationData previousCorrelation = Correlation.CurrentCorrelation;
                for (int i = 0; i < (new Random()).Next(3, 10); i++)
                {
                    Correlation.CorrelationStart(null);
                    CorrelationData parentCorrelation = Correlation.CurrentCorrelation.ParentCorrelation;
                    Assert.Same(previousCorrelation, parentCorrelation);
                    previousCorrelation = Correlation.CurrentCorrelation;
                }

                Assert.NotNull(Correlation.CurrentCorrelation);

                Correlation.CorrelationClear();

                Assert.Null(Correlation.CurrentCorrelation);
            }
            finally
            {
                EndRequest();
            }
        }
コード例 #2
0
        public void SettingShouldLogDirectly_OnBaseCorrelation_ShouldBeInheritedByCurrentCorrelation()
        {
            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;

                Correlation.CorrelationStart(null);

                Assert.True(Correlation.ShouldLogDirectly, "ShouldLogDirectly should be set to true.");
                Correlation.CorrelationClear();
            }
            finally
            {
                EndRequest();
            }
        }