Exemplo n.º 1
0
        public void ReportFailure(string message, Exception exception)
        {
            string completeMessage = $"Unexpected {message}";

            completeMessage = VerificationUtils.AppendExceptionToFailureMessage(completeMessage, exception);

            string       stackTrace = VerificationUtils.BuildStackTraceForAggregateAssertion();
            AtataContext context    = AtataContext.Current;

            context.AssertionResults.Add(AssertionResult.ForWarning(completeMessage, stackTrace));
            context.Log.Warn(completeMessage);

            context.WarningReportStrategy.Report(completeMessage, stackTrace);
        }
Exemplo n.º 2
0
        public void ReportFailure(string message, Exception exception)
        {
            string completeMessage = $"Wrong {message}";

            string completeMessageWithException = VerificationUtils.AppendExceptionToFailureMessage(completeMessage, exception);
            string stackTrace = VerificationUtils.BuildStackTraceForAggregateAssertion();

            AtataContext context = AtataContext.Current;

            context.AssertionResults.Add(AssertionResult.ForFailure(completeMessageWithException, stackTrace));

            if (context.AggregateAssertionLevel == 0)
            {
                throw VerificationUtils.CreateAssertionException(completeMessage, exception);
            }
            else
            {
                context.Log.Error(completeMessage);
                context.AggregateAssertionStrategy.ReportFailure(completeMessageWithException, stackTrace);
            }
        }
Exemplo n.º 3
0
        public void ReportFailure(string message, Exception exception)
        {
            string completeMessage = $"Unexpected {message}";
            string completeMessageWithException = VerificationUtils.AppendExceptionToFailureMessage(completeMessage, exception);

            string       stackTrace = VerificationUtils.BuildStackTraceForAggregateAssertion();
            AtataContext context    = AtataContext.Current;

            if (context != null)
            {
                context.AssertionResults.Add(AssertionResult.ForWarning(completeMessageWithException, stackTrace));
                context.Log.Warn(completeMessageWithException);

                context.WarningReportStrategy.Report(completeMessageWithException, stackTrace);
            }
            else
            {
                throw new InvalidOperationException(
                          $"Cannot report warning to {nameof(AtataContext)}.{nameof(AtataContext.Current)} as current context is null.",
                          VerificationUtils.CreateAssertionException(completeMessage, exception));
            }
        }