コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
        }