public void TestNullKeyNullValue() { var entry = new CorrelationContextEntry(null, null); Assert.Empty(entry.Key); Assert.Empty(entry.Value); }
public void TestNullValue() { var entry = new CorrelationContextEntry("foo", null); Assert.Equal("foo", entry.Key); Assert.Empty(entry.Value); }
public void TestGetHashCode() { var entry1 = new CorrelationContextEntry("key1", "value1"); Assert.NotEqual(0, entry1.GetHashCode()); var entry2 = new CorrelationContextEntry(null, "value1"); Assert.NotEqual(0, entry2.GetHashCode()); }
public void TestToString() { var entry1 = new CorrelationContextEntry("key1", "value1"); Assert.Equal("CorrelationContextEntry{Key=key1, Value=value1}", entry1.ToString()); var entry2 = new CorrelationContextEntry(null, "value1"); Assert.Equal("CorrelationContextEntry{Key=, Value=value1}", entry2.ToString()); }
public void TestEquality() { var entry1 = new CorrelationContextEntry("key", "value1"); var entry2 = new CorrelationContextEntry("key", "value1"); object entry3 = entry2; var entry4 = new CorrelationContextEntry("key", "value2"); Assert.True(entry1 == entry2); Assert.True(entry1.Equals(entry2)); Assert.True(entry1.Equals(entry3)); Assert.True(entry1 != entry4); }
public void TestTagEquals() { var tag1 = new CorrelationContextEntry("Key", "foo"); var tag2 = new CorrelationContextEntry("Key", "foo"); var tag3 = new CorrelationContextEntry("Key", "bar"); var tag4 = new CorrelationContextEntry("Key2", "foo"); Assert.Equal(tag1, tag2); Assert.NotEqual(tag1, tag3); Assert.NotEqual(tag1, tag4); Assert.NotEqual(tag2, tag3); Assert.NotEqual(tag2, tag4); Assert.NotEqual(tag3, tag4); }
/// <summary> /// Check whether <see cref="CorrelationContextEntry"/> matches this filter pattern. /// </summary> /// <param name="entry">Distributed Context entry to check.</param> /// <returns>True if <see cref="CorrelationContextEntry"/> matches this filter, false - otherwise.</returns> public bool IsMatch(CorrelationContextEntry entry) { bool result = false; switch (this.Operator) { case FilterMatchOperator.Equal: result = entry.Key.Equals(this.MatchString); break; case FilterMatchOperator.NotEqual: result = !entry.Key.Equals(this.MatchString); break; case FilterMatchOperator.HasPrefix: result = entry.Key.StartsWith(this.MatchString, StringComparison.Ordinal); break; } if (result) { this.Action(entry); } return(result); }
private static void EncodeTag(CorrelationContextEntry tag, MemoryStream byteArrayDataOutput) { byteArrayDataOutput.WriteByte(TagFieldId); EncodeString(tag.Key, byteArrayDataOutput); EncodeString(tag.Value, byteArrayDataOutput); }