コード例 #1
0
        /// <summary>
        /// Assert that given the input sample, the boolean expression will be
        /// true for all comparisons with the functionValue.
        /// </summary>
        /// <param name="sample">The input sample used to generate the functionValue</param>
        /// <param name="functionValue">The value generated by the function under test</param>
        /// <param name="comparison">The boolean expression to evaluate the functionValue against</param>
        internal void Assert <TOutput>(TInput sample, TOutput functionValue, IComparison comparison)
        {
            switch (comparison)
            {
            case BlockComparison blockComparison:
                AssertBlock(sample, functionValue, blockComparison);
                break;

            case FunctionComparison <TInput> functionComparison:
                if (!(functionValue is IComparable))
                {
                    throw new PropertyException("Attempted to compare output values that are not of type IComparable");
                }

                AssertFunction(sample, (IComparable)functionValue, functionComparison);
                break;

            case FunctionEqualityComparison <TInput> functionEqualityComparison:
                AssertFunctionEquality(sample, functionValue, functionEqualityComparison);
                break;

            default:
                throw new PropertyException($"Unexpected comparison type {comparison.GetType().Name}");
            }
        }