public async Task PropertiesAreCollectedInAnActiveContext() { var dc = new DiagnosticContext(Some.Logger()); var collector = dc.BeginCollection(); dc.Set(Some.String("first"), Some.Int32()); await Task.Delay(TimeSpan.FromMilliseconds(10)); dc.Set(Some.String("second"), Some.Int32()); Assert.True(collector.TryComplete(out var properties)); Assert.Equal(2, properties.Count()); Assert.False(collector.TryComplete(out _)); collector.Dispose(); dc.Set(Some.String("third"), Some.Int32()); Assert.False(collector.TryComplete(out _)); }
public void SetIsSafeWhenNoContextIsActive() { var dc = new DiagnosticContext(Some.Logger()); dc.Set(Some.String("name"), Some.Int32()); }