예제 #1
0
        public QueryResponseBuilder(QueryExpression queryExpression)
        {
            EnsureArg.IsNotNull(queryExpression, nameof(queryExpression));
            EnsureArg.IsFalse(queryExpression.IELevel == ResourceType.Frames, nameof(queryExpression.IELevel));

            Initialize(queryExpression);
        }
예제 #2
0
        public void IsFalse_WhenFalseExpression_ShouldNotThrow()
        {
            var returnedValue = Ensure.That(false, ParamName).IsFalse();

            AssertReturnedAsExpected(returnedValue, false);

            Action a = () => EnsureArg.IsFalse(false, ParamName);

            a.ShouldNotThrow();
        }
예제 #3
0
        public void IsFalse_WhenTrueExpression_ThrowsArgumentException()
        {
            var ex = Assert.Throws <ArgumentException>(() => Ensure.That(true, ParamName).IsFalse());

            AssertThrowedAsExpected(ex, ExceptionMessages.Booleans_IsFalseFailed);

            var ex2 = Assert.Throws <ArgumentException>(() => EnsureArg.IsFalse(true, ParamName));

            AssertThrowedAsExpected(ex2, ExceptionMessages.Booleans_IsFalseFailed);
        }
예제 #4
0
        /// <summary>
        /// Compares two observations to see if they are different.  If they are different the <paramref name="updatedObservation"/> status is changed to Amended.
        /// </summary>
        /// <param name="originalObservation">The original unmodified observation.</param>
        /// <param name="updatedObservation">The potentially modified observation.</param>
        /// <returns>Returns true if the <paramref name="updatedObservation"/> is different than the <paramref name="originalObservation"/>.  Otherwise false is returned.</returns>
        public static bool AmendIfChanged(this Observation originalObservation, Observation updatedObservation)
        {
            EnsureArg.IsNotNull(originalObservation, nameof(originalObservation));
            EnsureArg.IsNotNull(updatedObservation, nameof(updatedObservation));
            EnsureArg.IsFalse(originalObservation == updatedObservation, optsFn: o => o.WithMessage($"Parameters {nameof(originalObservation)} and {nameof(updatedObservation)} are the same reference."));

            if (!originalObservation.IsExactly(updatedObservation))
            {
                updatedObservation.Status = ObservationStatus.Amended;
                return(true);
            }

            return(false);
        }
예제 #5
0
 public void IsFalse_WhenFalseExpression_ShouldNotThrow() => ShouldNotThrow(
     () => Ensure.That(false, ParamName).IsFalse(),
     () => EnsureArg.IsFalse(false, ParamName));
예제 #6
0
 public void IsFalse_WhenTrueExpression_ThrowsArgumentException() => ShouldThrow <ArgumentException>(
     ExceptionMessages.Booleans_IsFalseFailed,
     () => Ensure.That(true, ParamName).IsFalse(),
     () => EnsureArg.IsFalse(true, ParamName));