public static void HasAttributes(IEnumerable <ExpectedAttribute> expectedAttributes, AttributeClassification attributeClassification, CustomEventWireModel customEvent) { var succeeded = true; var builder = new StringBuilder(); var actualAttributes = customEvent.GetAttributes(attributeClassification); 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 expectedValue = expectedAttribute.Value; var actualValue = actualAttributes[expectedAttribute.Key] as string; if (expectedValue != null && actualValue != expectedAttribute.Value as string) { 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()); }
public static void DoesNotHaveAttributes(IEnumerable <string> unexpectedAttributes, AttributeClassification attributeClassification, CustomEventWireModel customEvent) { var succeeded = true; var builder = new StringBuilder(); var actualAttributes = customEvent.GetAttributes(attributeClassification); 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()); }