public void ExtractRunnableStructCheckWorks()
        {
            var runnableStructCheck = ExtensibilityHelper.ExtractStructChecker(new FluentStructCheck <Nationality>(Nationality.Chinese));

            Check.ThatEnum(runnableStructCheck.Value).IsEqualTo(Nationality.Chinese);
            Check.That(runnableStructCheck.Negated).IsFalse();
        }
Exemple #2
0
        /// <summary>
        /// Checks that the actual value is not equal to another expected value.
        /// </summary>
        /// <typeparam name="T">Type of the struct or the enum to assert on.</typeparam>
        /// <param name="check">The fluent check to be extended.</param>
        /// <param name="expected">The expected value.</param>
        /// <returns>
        /// A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">The actual value is equal to the expected value.</exception>
        public static ICheckLink <IStructCheck <T> > IsNotEqualTo <T>(this IStructCheck <T> check, object expected) where T : struct
        {
            var runnableStructCheck = ExtensibilityHelper.ExtractStructChecker(check);

            return(runnableStructCheck.ExecuteCheck(
                       () => EqualityHelper.IsNotEqualTo(runnableStructCheck, expected),
                       EqualityHelper.BuildErrorMessage(runnableStructCheck, expected, false)));
        }
Exemple #3
0
        /// <summary>
        /// Checks that the actual value is equal to another expected value.
        /// </summary>
        /// <typeparam name="T">Type of the struct or the enum to assert on.</typeparam>
        /// <param name="check">The fluent fluent check.</param>
        /// <param name="expected">The expected value.</param>
        /// <returns>
        /// A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">The actual value is not equal to the expected value.</exception>
        public static ICheckLink <IStructCheck <T> > IsEqualTo <T>(this IStructCheck <T> check, T expected) where T : struct
        {
            var runnableStructCheck = ExtensibilityHelper.ExtractStructChecker(check);

            return(runnableStructCheck.ExecuteCheck(
                       () =>
            {
                EqualityHelper.IsEqualTo(runnableStructCheck.Value, expected);
            },
                       EqualityHelper.BuildErrorMessage(runnableStructCheck.Value, expected, true)));
        }
        public static ICheckLink <IStructCheck <Nationality> > IsEuropean(this IStructCheck <Nationality> check)
        {
            var structChecker = ExtensibilityHelper.ExtractStructChecker(check);

            return(structChecker.ExecuteCheck(
                       () =>
            {
                if (!structChecker.Value.Equals(Nationality.English) && !structChecker.Value.Equals(Nationality.German) && !structChecker.Value.Equals(Nationality.Serbian) && !structChecker.Value.Equals(Nationality.French))
                {
                    var message = FluentMessage.BuildMessage("The {0} is not part of Europe.").For("Nationality").On(structChecker.Value).ToString();
                    throw new FluentCheckException(message);
                }
            },
                       FluentMessage.BuildMessage("The {0} is part of Europe whereas it must not.").For("Nationality").On(structChecker.Value).ToString()));
        }
        public static ICheckLink <IStructCheck <Nationality> > IsOccidental(this IStructCheck <Nationality> check)
        {
            var structChecker = ExtensibilityHelper.ExtractStructChecker(check);

            return(structChecker.BuildChainingObject());
        }
        public static ICheckLink <IStructCheck <Nationality> > IsOccidental(this IStructCheck <Nationality> check)
        {
            var structChecker = ExtensibilityHelper.ExtractStructChecker(check);

            return(structChecker.ReturnValueForLinkage);
        }
Exemple #7
0
        /// <summary>
        /// Checks that the actual value is not equal to another expected value.
        /// </summary>
        /// <typeparam name="T">Type of the struct or the enum to assert on.</typeparam>
        /// <param name="check">The fluent check to be extended.</param>
        /// <param name="expected">The expected value.</param>
        /// <returns>
        /// A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">The actual value is equal to the expected value.</exception>
        public static ICheckLink <IStructCheck <T> > IsNotEqualTo <T>(this IStructCheck <T> check, object expected) where T : struct
        {
            var runnableStructCheck = ExtensibilityHelper.ExtractStructChecker(check);

            return(EqualityHelper.PerformEqualCheck(runnableStructCheck, expected, false, true));
        }
Exemple #8
0
        /// <summary>
        /// Checks that the actual value is equal to another expected value.
        /// </summary>
        /// <typeparam name="T">Type of the struct or the enum to assert on.</typeparam>
        /// <param name="check">The fluent fluent check.</param>
        /// <param name="expected">The expected value.</param>
        /// <returns>
        /// A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">The actual value is not equal to the expected value.</exception>
        public static ICheckLink <IStructCheck <T> > IsEqualTo <T>(this IStructCheck <T> check, T expected) where T : struct
        {
            var checker = ExtensibilityHelper.ExtractStructChecker(check);

            return(EqualityHelper.PerformEqualCheck(checker, expected, false));
        }