示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <returns>Violation message</returns>
        internal static Violation WhenEnumOutOfRange <T>([CanBeNull] string name, [JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] object value)
        {
            string enumType  = typeof(T).Name;
            string enumValue = value.ToString();

            name = name ?? "enum";

            return(Violation.Of($"Unsupported {name} value: {enumValue} ({enumType})"));
        }
示例#2
0
 /// <summary>
 /// "'{0}' is true; and it should be false;"
 /// </summary>
 /// <param name="name"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenVariableIsTrue([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string name) => Violation.Of("'{0}' is true; and it should be false;", name);
示例#3
0
 /// <summary>
 /// "Argument '{0}' is null."
 /// </summary>
 /// <param name="argumentName"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenArgumentIsNull([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string argumentName) => Violation.Of("Argument '{0}' is null.", argumentName);
示例#4
0
 /// <summary>
 /// "Expected {0} of type '{1}' but was '{2}'"
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 internal static Violation WhenCannotCast <T>([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string name, [CanBeNull] object value) =>
 Violation.Of("Expected {0} of type '{1}' but was '{2}'", name, typeof(T), FormatValue(value));
示例#5
0
 /// <summary>
 /// "Collection '{0}' contains null"
 /// </summary>
 /// <param name="collectionName"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenCollectionContainsNull([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string collectionName) =>
 Violation.Of("Collection '{0}' contains null", collectionName);
示例#6
0
 /// <summary>
 /// "Collection '{0}' should not be empty but it is."
 /// </summary>
 /// <param name="collectionName"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenCollectionIsEmpty([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string collectionName) =>
 Violation.Of("Collection '{0}' should not be empty but it is.", collectionName);
示例#7
0
 /// <summary>
 /// "Argument '{0}' is an empty Guid."
 /// </summary>
 /// <param name="name"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenGuidArgumentIsEmpty([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string name) => Violation.Of("Argument '{0}' is an empty Guid.", name);
示例#8
0
 /// <summary>
 /// "'{0}' is empty = {1}"
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenDateTimeIsEmpty(string name, DateTime value) =>
 Violation.Of("'{0}' is empty = {1}", name, value.ToString(CultureInfo.InvariantCulture));
示例#9
0
 /// <summary>
 /// '{0}' is NOT equal to {1} and it should be.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="expected"></param>
 /// <param name="actual"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenNotEqual <TExpected, TActual>([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string name, [CanBeNull] TExpected expected, [CanBeNull] TActual actual) =>
 Violation.Of("'{0}' ({2}) is NOT equal to {1} and it should be.", name, Violation.FormatValue(expected), Violation.FormatValue(actual));
示例#10
0
 /// <summary>
 /// "Argument '{0}' is equal to {1} and it should NOT be."
 /// </summary>
 /// <param name="name"></param>
 /// <param name="unexpected"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenArgumentEqual <T>([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string name, [CanBeNull] T unexpected) =>
 Violation.Of("Argument '{0}' is equal to {1} and it should NOT be.", name, Violation.FormatValue(unexpected));
示例#11
0
 /// <summary>
 /// "'{0}' is too long - {1} (max: {2})"
 /// </summary>
 /// <param name="name"></param>
 /// <param name="currentLength"></param>
 /// <param name="maxLength"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenTooLong([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string name, int currentLength, int maxLength) =>
 Violation.Of("'{0}' is too long - {1} (max: {2})", name, currentLength, maxLength);
示例#12
0
 /// <summary>
 /// "'{0}' is whitespace"
 /// </summary>
 /// <param name="name"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenWhitespace([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string name) => Violation.Of("'{0}' is whitespace", name);
示例#13
0
 /// <summary>
 /// "'{0}' is empty."
 /// </summary>
 /// <param name="name"></param>
 /// <returns>Violation message</returns>
 internal static Violation WhenEmpty([JetBrains.Annotations.NotNull][System.Diagnostics.CodeAnalysis.NotNull] string name) => Violation.Of("'{0}' is empty.", name);