Exemplo n.º 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})"));
        }
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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));
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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));
Exemplo n.º 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));
Exemplo n.º 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));
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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);