public QueryResponseBuilder(QueryExpression queryExpression) { EnsureArg.IsNotNull(queryExpression, nameof(queryExpression)); EnsureArg.IsFalse(queryExpression.IELevel == ResourceType.Frames, nameof(queryExpression.IELevel)); Initialize(queryExpression); }
public void IsFalse_WhenFalseExpression_ShouldNotThrow() { var returnedValue = Ensure.That(false, ParamName).IsFalse(); AssertReturnedAsExpected(returnedValue, false); Action a = () => EnsureArg.IsFalse(false, ParamName); a.ShouldNotThrow(); }
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); }
/// <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); }
public void IsFalse_WhenFalseExpression_ShouldNotThrow() => ShouldNotThrow( () => Ensure.That(false, ParamName).IsFalse(), () => EnsureArg.IsFalse(false, ParamName));
public void IsFalse_WhenTrueExpression_ThrowsArgumentException() => ShouldThrow <ArgumentException>( ExceptionMessages.Booleans_IsFalseFailed, () => Ensure.That(true, ParamName).IsFalse(), () => EnsureArg.IsFalse(true, ParamName));