public IDictionary <string, object> GetByType(TransactionEventAttributeType attributeType) { IDictionary <string, object> attributes; switch (attributeType) { case TransactionEventAttributeType.Intrinsic: attributes = IntrinsicAttributes; break; case TransactionEventAttributeType.Agent: attributes = AgentAttributes; break; case TransactionEventAttributeType.User: attributes = UserAttributes; break; default: throw new NotImplementedException(); } return(attributes ?? new Dictionary <string, object>()); }
public static void TransactionEventHasAttributes(IEnumerable <string> expectedAttributes, TransactionEventAttributeType attributeType, TransactionEvent transactionEvent) { var succeeded = true; var builder = new StringBuilder(); var actualAttributes = transactionEvent.GetByType(attributeType); foreach (var expectedAttribute in expectedAttributes) { if (!actualAttributes.ContainsKey(expectedAttribute)) { builder.AppendFormat("Attribute named {0} was not found in the transaction event.", expectedAttribute); builder.AppendLine(); succeeded = false; } } Assert.True(succeeded, builder.ToString()); }
public static void TransactionEventDoesNotHaveAttributes(IEnumerable <string> unexpectedAttributes, TransactionEventAttributeType attributeType, TransactionEvent transactionEvent) { var succeeded = true; var builder = new StringBuilder(); var actualAttributes = transactionEvent.GetByType(attributeType); foreach (var unexpectedAttribute in unexpectedAttributes) { if (actualAttributes.ContainsKey(unexpectedAttribute)) { builder.AppendFormat("Attribute named {0} was found in the transaction event but it should not have been.", unexpectedAttribute); builder.AppendLine(); succeeded = false; } } Assert.True(succeeded, builder.ToString()); }
public static void TransactionEventHasAttributes(IEnumerable <KeyValuePair <string, string> > expectedAttributes, TransactionEventAttributeType attributeType, TransactionEvent transactionEvent) { var succeeded = true; var builder = new StringBuilder(); var actualAttributes = transactionEvent.GetByType(attributeType); foreach (var expectedAttribute in expectedAttributes) { if (!actualAttributes.ContainsKey(expectedAttribute.Key)) { builder.AppendFormat("Attribute named {0} was not found in the transaction event.", expectedAttribute); builder.AppendLine(); succeeded = false; continue; } var actualValue = actualAttributes[expectedAttribute.Key] as string; if (actualValue != expectedAttribute.Value) { builder.AppendFormat("Attribute named {0} in the transaction event had an unexpected value. Expected: {1}, Actual: {2}", expectedAttribute.Key, expectedAttribute.Value, actualValue); builder.AppendLine(); succeeded = false; continue; } } Assert.True(succeeded, builder.ToString()); }