Ejemplo n.º 1
0
        public IDictionary <string, object> GetByType(ErrorTraceAttributeType attributeType)
        {
            IDictionary <string, object> attributes;

            switch (attributeType)
            {
            case ErrorTraceAttributeType.Intrinsic:
                attributes = IntrinsicAttributes;
                break;

            case ErrorTraceAttributeType.Agent:
                attributes = AgentAttributes;
                break;

            case ErrorTraceAttributeType.User:
                attributes = UserAttributes;
                break;

            default:
                throw new NotImplementedException();
            }

            return(attributes ?? new Dictionary <string, object>());
        }
Ejemplo n.º 2
0
        public static void ErrorTraceDoesNotHaveAttributes(IEnumerable <string> unexpectedAttributes, ErrorTraceAttributeType attributeType, ErrorTrace errorTrace)
        {
            var succeeded        = true;
            var builder          = new StringBuilder();
            var actualAttributes = errorTrace.Attributes.GetByType(attributeType);

            foreach (var unexpectedAttribute in unexpectedAttributes)
            {
                if (actualAttributes.ContainsKey(unexpectedAttribute))
                {
                    builder.AppendFormat("Attribute named {0} was found in the error trace but it should not have been.", unexpectedAttribute);
                    builder.AppendLine();
                    succeeded = false;
                }
            }

            Assert.True(succeeded, builder.ToString());
        }
Ejemplo n.º 3
0
        public static void ErrorTraceHasAttributes(IEnumerable <string> expectedAttributes, ErrorTraceAttributeType attributeType, ErrorTrace errorTrace)
        {
            var succeeded = true;
            var builder   = new StringBuilder();

            foreach (var expectedAttribute in expectedAttributes)
            {
                if (!errorTrace.Attributes.GetByType(attributeType).ContainsKey(expectedAttribute))
                {
                    builder.AppendFormat("Attribute named {0} was not found in the error trace.", expectedAttribute);
                    builder.AppendLine();
                    succeeded = false;
                    continue;
                }
            }

            Assert.True(succeeded, builder.ToString());
        }
Ejemplo n.º 4
0
        public static void ErrorTraceHasAttributes(IEnumerable <KeyValuePair <string, string> > expectedAttributes, ErrorTraceAttributeType attributeType, ErrorTrace errorTrace)
        {
            var succeeded = true;
            var builder   = new StringBuilder();

            foreach (var expectedAttribute in expectedAttributes)
            {
                if (!errorTrace.Attributes.GetByType(attributeType).ContainsKey(expectedAttribute.Key))
                {
                    builder.AppendFormat("Attribute named {0} was not found in the error trace.", expectedAttribute);
                    builder.AppendLine();
                    succeeded = false;
                    continue;
                }
                var attribute   = errorTrace.Attributes.GetByType(attributeType)[expectedAttribute.Key];
                var actualValue = attribute as string;

                if (actualValue == null && attribute.GetType() == typeof(bool))
                {
                    actualValue = attribute.ToString().ToLowerInvariant();
                }

                if (actualValue != expectedAttribute.Value)
                {
                    builder.AppendFormat("Attribute named {0} in the error trace had an unexpected value.  Expected: {1}, Actual: {2}", expectedAttribute.Key, expectedAttribute.Value, actualValue);
                    builder.AppendLine();
                    succeeded = false;
                    continue;
                }
            }

            Assert.True(succeeded, builder.ToString());
        }