public void ShouldPassCallbackEvaluationWithMessage() { // given Func <bool> condition = () => true; const string errorMessage = "test"; // when var result = Try.To(() => Precognitions.Evaluate(condition, errorMessage)); // then var caughtException = result.IsFailure ? result.Error : null; Check.That(caughtException).IsNull(); }
public void ShouldPassEvalitionWithException() { // given const bool condition = true; const string errorMessage = "test"; Func <ApplicationException> exception = () => new ApplicationException(errorMessage); // when var result = Try.To(() => Precognitions.Evaluate(condition, exception)); // then var caughtException = result.IsFailure ? result.Error : null; Check.That(caughtException).IsNull(); }
public void ShouldThrowArgumentExceptionOnEvaluationWithMessage() { // given const bool condition = false; const string errorMessage = "test"; // when var result = Try.To(() => Precognitions.Evaluate(condition, errorMessage)); // then var caughtException = result.IsFailure ? result.Error : null; Check.That(caughtException).IsNotNull(); Check.That(caughtException).IsInstanceOf <ArgumentException>(); Check.That(caughtException.Message).IsEqualTo(errorMessage); }