public void LogContextConstructorInitializersTest() { LogContext logContext = new LogContext(); Dictionary <string, object> logContextTags = logContext.GetDictionary(); Assert.True(logContextTags.ContainsKey("LogContextID")); Assert.NotEqual(Guid.Parse((string)logContextTags["LogContextID"]), Guid.Empty); }
public void LogContextAddAndRemoveTagsTest() { string tagKey = "teste1"; string tagValue = DateTime.Now.Ticks.ToString(); using (LogContext logContext = new LogContext(true)) { Assert.False(logContext.GetDictionary().ContainsKey(tagKey)); logContext.SetValue(tagKey, tagValue); Assert.True(logContext.GetDictionary().ContainsKey(tagKey)); Assert.Equal(logContext.GetDictionary()[tagKey], tagValue); //removing unknow tag does not result in exception logContext.Remove(DateTime.Now.Ticks.ToString()); logContext.Remove(tagKey); Assert.False(logContext.GetDictionary().ContainsKey(tagKey)); } }