/// <summary>
        /// Asserts that the comparison is met, within the bounds of the precision.  On failure, the test framework is used to trigger the failure
        /// </summary>
        /// <param name="testFramework">The test framework to be used for assertions</param>
        /// <param name="expectedDate">The expected date to be used in the comparison</param>
        /// <param name="value">The value being tested</param>
        /// <param name="message">The prefix of the message to be used in the failure message</param>
        protected void AssertDate(ITestFramework testFramework, DateTime expectedDate, DateTime value, string message)
        {
            TimeSpan difference = value - expectedDate;

            if (difference.Duration() >= Precision)
            {
                testFramework.AreEqual(expectedDate, value, message, $"{difference.TotalMilliseconds} ms");
            }
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public void Assert(ITestFramework testFramework, object value, string messagePrefix)
        {
            if (value == null)
            {
                value = string.Empty;
            }
            testFramework.IsInstanceOfType(value, typeof(string), $"{messagePrefix} is not a valid String object");

            testFramework.AreEqual(ExpectedLength, ((string)value)?.Length ?? 0, $"{messagePrefix} has an unexpected length");
        }
Esempio n. 3
0
        /// <inheritdoc/>
        public void Assert(ITestFramework testFramework, object value, string messagePrefix)
        {
            testFramework.IsInstanceOfType(value, typeof(DateTime), $"{messagePrefix} is not a valid DateTime object");

            DateTime actualDay = GetDateDay((DateTime)value);

            TimeSpan difference = actualDay - ExpectedDateDay;

            testFramework.AreEqual(ExpectedDateDay,
                                   actualDay,
                                   $"{messagePrefix} is different by {{0}}",
                                   $"{difference.TotalDays} day{(Math.Abs(difference.TotalDays) == 1 ? "" : "s")}");
        }
Esempio n. 4
0
        /// <summary>
        /// <para>Asserts that the value is correct, according to the expected value.</para>
        /// <para>Where the expected value is a native type, object equality is used as the test.  Where the expected value is an <see cref="IComparison"/> object, the specific <see cref="IComparison"/> assertion logic is used</para>
        /// </summary>
        /// <param name="testFramework">The test framework to use for assertions</param>
        /// <param name="expectedValue">The expected value.  This can be either a native type or an <see cref="IComparison"/> object</param>
        /// <param name="value">The value to test</param>
        /// <param name="messagePrefix">The prefix of the message to use during assertion failure</param>
        public static void Assert(ITestFramework testFramework, object expectedValue, object value, string messagePrefix)
        {
            expectedValue = expectedValue ?? DBNull.Value;
            value         = value ?? DBNull.Value;

            if (expectedValue is IComparison comparisonValue)
            {
                comparisonValue.Assert(testFramework, value, messagePrefix);
            }
            else
            {
                testFramework.AreEqual(expectedValue, value, $"{messagePrefix} has an unexpected value");
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Asserts the number of rows
 /// </summary>
 /// <param name="expected">The expected number of rows</param>
 /// <returns>Returns the same <see cref="QueryResult"/> object</returns>
 public QueryResult AssertRowCount(int expected)
 {
     TestFramework.AreEqual(expected, TotalRows, $"The total row count is unexpected");
     return(this);
 }
Esempio n. 6
0
 /// <inheritdoc/>
 public void Assert(ITestFramework testFramework, object value, string messagePrefix)
 {
     testFramework.AreEqual(DBNull.Value, value ?? DBNull.Value, $"{messagePrefix} has an unexpected state");
 }