Exemple #1
0
        public void ExceptionFromWhenActionIsOptional()
        {
            var exception1            = GetCaughtAssertException("Check 1 failed");
            var exception2            = GetCaughtAssertException("Check 2 failed");
            var exceptionChecksFailed = new ExceptionChecksFailed(ImmutableArray.Create(exception1, exception2));

            exceptionChecksFailed.Message.Should().Be(
                $"{Environment.NewLine}" +
                $"No exception was thrown in When action.{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"Failed exception checks:{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"1) {exception1.Message}{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"2) {exception2.Message}{Environment.NewLine}");
            exceptionChecksFailed.ToString().Should().Be(
                $"{Environment.NewLine}" +
                $"No exception was thrown in When action.{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"Failed exception checks:{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"1) {exception1.Message}{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"2) {exception2.Message}{Environment.NewLine}");
        }
Exemple #2
0
        public void OwnStackTraceIsOmitted()
        {
            var exception1            = GetCaughtException();
            var exception2            = GetCaughtAssertException("Check 1 failed");
            var exception3            = GetCaughtAssertException("Check 2 failed");
            var exceptionChecksFailed = new ExceptionChecksFailed(exception1,
                                                                  ImmutableArray.Create(exception2, exception3));

            exceptionChecksFailed.StackTrace.Should().Be($"Stack trace of {nameof(ExceptionChecksFailed)} is omitted.");
        }
Exemple #3
0
        public void ToStringIsAggregatedForExceptionFromWhenActionAndExceptionChecks()
        {
            var exception1            = GetCaughtException();
            var exception2            = GetCaughtAssertException("Check 1 failed");
            var exception3            = GetCaughtAssertException("Check 2 failed");
            var exceptionChecksFailed = new ExceptionChecksFailed(exception1,
                                                                  ImmutableArray.Create(exception2, exception3));

            exceptionChecksFailed.ToString().Should().Be(
                $"{Environment.NewLine}" +
                $"Unexpected exception was thrown in When action:{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"{exception1.Message}{Environment.NewLine}" +
                $"{exception1.StackTrace}{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"Failed exception checks:{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"1) {exception2.Message}{Environment.NewLine}" +
                $"{Environment.NewLine}" +
                $"2) {exception3.Message}{Environment.NewLine}");
        }