Пример #1
0
        /// <inheritdoc />
        public void HandleValueMismatch(string expectedValue, string actualValue, string reason, params object[] reasonArgs)
        {
            expectedValue = expectedValue ?? "match";
            actualValue   = actualValue ?? MessageFormatter.FormatValue(this.Value);

            var message = MessageFormatter.Format(
                "The parameter '{0}' value shall {1}{2} but was {3}.",
                this.Name,
                expectedValue,
                MessageFormatter.FormatReason(reason, reasonArgs),
                actualValue);

            throw new ArgumentOutOfRangeException(this.Name, this.Value, message);
        }
Пример #2
0
        /// <inheritdoc />
        public void HandleValueMismatch(string expectedValue, string actualValue, string reason, params object[] reasonArgs)
        {
            expectedValue = expectedValue ?? "match";
            actualValue   = actualValue ?? MessageFormatter.FormatValue(this.Value);

            var message = MessageFormatter.Format(
                "The return value of method '{0}' shall {1}{2} but was {3}.",
                this.Name,
                expectedValue,
                MessageFormatter.FormatReason(reason, reasonArgs),
                actualValue);

            throw new InvalidOperationException(message);
        }