コード例 #1
0
        /// <summary>
        /// Constructs an assertion failure.
        /// </summary>
        /// <param name="native">The native unmanged object describing the failure.</param>
        /// <param name="stringResolver">A service to resolve unmanaged unicode strings.</param>
        public MbUnitCppAssertionFailure(NativeAssertionFailure native, IStringResolver stringResolver)
        {
            description        = stringResolver.GetString(native.DescriptionId);
            message            = stringResolver.GetString(native.MessageId);
            hasActualValue     = native.ActualValue.IsValid;
            hasExpectedValue   = native.ExpectedValue.IsValid;
            hasUnexpectedValue = native.UnexpectedValue.IsValid;
            line = native.Line;

            if (hasActualValue)
            {
                actualValue = NativeValueParser.Parse(stringResolver.GetString(native.ActualValue.ValueId), native.ActualValue.ValueType);
            }

            if (hasExpectedValue)
            {
                expectedValue = NativeValueParser.Parse(stringResolver.GetString(native.ExpectedValue.ValueId), native.ExpectedValue.ValueType);
            }

            if (hasUnexpectedValue)
            {
                unexpectedValue = NativeValueParser.Parse(stringResolver.GetString(native.UnexpectedValue.ValueId), native.UnexpectedValue.ValueType);
            }

            diffing = hasActualValue && (native.ActualValue.ValueType == NativeValueType.String) &&
                      ((hasExpectedValue && (native.ExpectedValue.ValueType == NativeValueType.String)) ||
                       (hasUnexpectedValue && (native.UnexpectedValue.ValueType == NativeValueType.String)));

            extraLabeledValues = GenericCollectionUtils.ToArray(GetExtraLabeledValues(native, stringResolver));
        }
コード例 #2
0
 private static IEnumerable <Pair <string, object> > GetExtraLabeledValues(NativeAssertionFailure native, IStringResolver stringResolver)
 {
     foreach (NativeLabeledValue item in new[] { native.Extra_0, native.Extra_1 })
     {
         if (item.IsValid)
         {
             yield return(new Pair <string, object>(
                              stringResolver.GetString(item.LabelId),
                              NativeValueParser.Parse(stringResolver.GetString(item.ValueId), item.ValueType)));
         }
     }
 }
コード例 #3
0
 private static IEnumerable<Pair<string, object>> GetExtraLabeledValues(NativeAssertionFailure native, IStringResolver stringResolver)
 {
     foreach (NativeLabeledValue item in new[] { native.Extra_0, native.Extra_1 })
     {
         if (item.IsValid)
         {
             yield return new Pair<string, object>(
                 stringResolver.GetString(item.LabelId),
                  NativeValueParser.Parse(stringResolver.GetString(item.ValueId), item.ValueType));
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// Constructs an assertion failure.
        /// </summary>
        /// <param name="native">The native unmanged object describing the failure.</param>
        /// <param name="stringResolver">A service to resolve unmanaged unicode strings.</param>
        public MbUnitCppAssertionFailure(NativeAssertionFailure native, IStringResolver stringResolver)
        {
            description = stringResolver.GetString(native.DescriptionId);
            message = stringResolver.GetString(native.MessageId);
            hasActualValue = native.ActualValue.IsValid;
            hasExpectedValue = native.ExpectedValue.IsValid;
            hasUnexpectedValue = native.UnexpectedValue.IsValid;
            line = native.Line;

            if (hasActualValue)
                actualValue = NativeValueParser.Parse(stringResolver.GetString(native.ActualValue.ValueId), native.ActualValue.ValueType);

            if (hasExpectedValue)
                expectedValue = NativeValueParser.Parse(stringResolver.GetString(native.ExpectedValue.ValueId), native.ExpectedValue.ValueType);

            if (hasUnexpectedValue)
                unexpectedValue = NativeValueParser.Parse(stringResolver.GetString(native.UnexpectedValue.ValueId), native.UnexpectedValue.ValueType);

            diffing = hasActualValue && (native.ActualValue.ValueType == NativeValueType.String) &&
                ((hasExpectedValue && (native.ExpectedValue.ValueType == NativeValueType.String)) ||
                (hasUnexpectedValue && (native.UnexpectedValue.ValueType == NativeValueType.String)));

            extraLabeledValues = GenericCollectionUtils.ToArray(GetExtraLabeledValues(native, stringResolver));
        }