public IDictionary <string, object> GetByType(EventAttributeType attributeType) { IDictionary <string, object> attributes; switch (attributeType) { case EventAttributeType.Intrinsic: attributes = IntrinsicAttributes; break; case EventAttributeType.Agent: attributes = AgentAttributes; break; case EventAttributeType.User: attributes = UserAttributes; break; default: throw new NotImplementedException(); } return(attributes ?? new Dictionary <string, object>()); }
public EventAttribute(string name, EventAttributeType type, object value) { this.name = name; this.type = type; this.value = value; }
public EventAttribute() { name = "Attribute"; type = EventAttributeType.Float; value = 0.0f; }
public static void ErrorEventDoesNotHaveAttributes(IEnumerable <string> unexpectedAttributes, EventAttributeType attributeType, ErrorEventEvents errorEvent) { var succeeded = true; var builder = new StringBuilder(); IDictionary <string, object> actualAttributes = null; switch (attributeType) { case EventAttributeType.Agent: actualAttributes = errorEvent.AgentAttributes; break; case EventAttributeType.Intrinsic: actualAttributes = errorEvent.IntrinsicAttributes; break; case EventAttributeType.User: actualAttributes = errorEvent.UserAttributes; break; } foreach (var unexpectedAttribute in unexpectedAttributes) { if (actualAttributes.ContainsKey(unexpectedAttribute)) { builder.AppendFormat("Attribute named {0} was found in the error event but it should not have been.", unexpectedAttribute); builder.AppendLine(); succeeded = false; } } Assert.True(succeeded, builder.ToString()); }
public static void ErrorEventHasAttributes(IEnumerable <string> expectedAttributes, EventAttributeType attributeType, ErrorEventEvents errorEvent) { var succeeded = true; var builder = new StringBuilder(); var actualAttributes = new List <string>(); switch (attributeType) { case EventAttributeType.Agent: actualAttributes = errorEvent.AgentAttributes.Keys.ToList(); break; case EventAttributeType.Intrinsic: actualAttributes = errorEvent.IntrinsicAttributes.Keys.ToList(); break; case EventAttributeType.User: actualAttributes = errorEvent.UserAttributes.Keys.ToList(); break; } foreach (var expectedAttribute in expectedAttributes) { if (!actualAttributes.Contains(expectedAttribute)) { builder.AppendFormat("Attribute name {0} was not found in error event", expectedAttribute); builder.AppendLine(); succeeded = false; } } Assert.True(succeeded, builder.ToString()); }
public static void ErrorEventHasAttributes(IEnumerable <KeyValuePair <string, string> > expectedAttributes, EventAttributeType attributeType, ErrorEventEvents errorEvent) { var succeeded = true; var builder = new StringBuilder(); IDictionary <string, object> actualAttributes = null; switch (attributeType) { case EventAttributeType.Agent: actualAttributes = errorEvent.AgentAttributes; break; case EventAttributeType.Intrinsic: actualAttributes = errorEvent.IntrinsicAttributes; break; case EventAttributeType.User: actualAttributes = errorEvent.UserAttributes; break; } foreach (var expectedAttribute in expectedAttributes) { if (!actualAttributes.ContainsKey(expectedAttribute.Key)) { builder.AppendFormat("Attribute named {0} was not found in the error event.", expectedAttribute); builder.AppendLine(); succeeded = false; continue; } var actualValue = actualAttributes[expectedAttribute.Key] as string; if (actualValue == null && actualAttributes[expectedAttribute.Key].GetType() == typeof(bool)) { actualValue = actualAttributes[expectedAttribute.Key].ToString().ToLowerInvariant(); } if (actualValue != expectedAttribute.Value) { builder.AppendFormat("Attribute named {0} in the error event had an unexpected value. Expected: {1}, Actual: {2}", expectedAttribute.Key, expectedAttribute.Value, actualValue); builder.AppendLine(); succeeded = false; continue; } } Assert.True(succeeded, builder.ToString()); }
public void AddAttribute(EventAttributeType key, Object value) { _attributeTable.Add(key, value); }
public object GetAttribute(EventAttributeType key) { return(_attributeTable[key]); }