FluentAssert.ExceptionConfiguration.CaughtExpectedException C# (CSharp) Method

CaughtExpectedException() public method

public CaughtExpectedException ( ) : void
return void
        public void CaughtExpectedException()
        {
            ExpectException = false;
        }

Usage Example

コード例 #1
0
        public static void Verify(StringBuilder scenarioDescription, ITestStep testStep, ExceptionConfiguration exceptionConfiguration)
        {
            scenarioDescription.Append(testStep.Description);
            try
            {
                testStep.Action();
                scenarioDescription.AppendLine(testStep.SuccessSuffix);
            }
            catch (Exception e)
            {
                if (!exceptionConfiguration.ExpectException)
                {
                    scenarioDescription.AppendLine(testStep.FailureSuffix);
                    Console.Error.WriteLine(scenarioDescription.ToString());
                    throw;
                }

                var exceptionType = e.GetType();
                if (exceptionType != exceptionConfiguration.ExpectedExceptionType)
                {
                    scenarioDescription.AppendLine(testStep.FailureSuffix);
                    Console.Error.WriteLine(scenarioDescription.ToString());
                    throw new AssertionException(String.Format("Expected exception of type {0} but caught type {1}",
                                                               exceptionConfiguration.ExpectedExceptionType,
                                                               exceptionType),
                                                 e);
                }

                if (exceptionConfiguration.ExpectExceptionMessage)
                {
                    if (e.Message != exceptionConfiguration.ExpectedExceptionMessage)
                    {
                        scenarioDescription.AppendLine(testStep.FailureSuffix);
                        Console.Error.WriteLine(scenarioDescription.ToString());
                        throw new AssertionException(String.Format("Expected exception message '{0}' but had '{1}'",
                                                                   exceptionConfiguration.ExpectedExceptionMessage,
                                                                   e.Message),
                                                     e);
                    }
                }

                exceptionConfiguration.CaughtExpectedException();
                scenarioDescription.AppendLine(testStep.SuccessSuffix);
            }
        }
All Usage Examples Of FluentAssert.ExceptionConfiguration::CaughtExpectedException