Exemplo n.º 1
0
 /// <summary>
 ///     Checks the current value is true.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <exception cref="ExpressionCheckFailure{T}"></exception>
 public void IsTrue(string message = null)
 {
     if (!_func(_value))
     {
         // ReSharper disable once UnthrowableException
         throw _factory.Build(
                   new ExpressionCheckFailure <T>(CheckType.True, _value, default(T), message, _expression));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Check that the properties are equal to properties of another type
        /// </summary>
        /// <param name="expected">The expected.</param>
        /// <param name="message">The message.</param>
        /// <exception cref="PropertiesCheckFailure{T}"></exception>
        public void AreEqualToPropertiesOf(T expected, string message = null)
        {
            var trace = new CheckingTrace();

            if (!ObjectComparer.PropertiesAreEqual(_value, expected, trace, _options))
            {
                // ReSharper disable once UnthrowableException
                throw _factory.Build(new PropertiesCheckFailure <T>(CheckType.PropertiesEqual, _value, expected, trace,
                                                                    message));
            }
        }
Exemplo n.º 3
0
        private void Throw(T expected, string message, CheckType checkType)
        {
            var equalCheckFailure = new EqualCheckFailure <T>(checkType, _value, expected, message);

            // ReSharper disable once UnthrowableException
            throw _factory.Build(equalCheckFailure);
        }
Exemplo n.º 4
0
 private void Check(bool flag, CheckType checkType, string message)
 {
     if (flag)
     {
         var checkFailure = new BoolCheckFailure(checkType, _value, !_value, message);
         // ReSharper disable once UnthrowableException
         throw _factory.Build(checkFailure);
     }
 }