CmdletUnitTest.TestRunspace.RunAndGetTheException C# (CSharp) Метод

RunAndGetTheException() публичный статический Метод

public static RunAndGetTheException ( string codeSnippet, string exceptionType, string message ) : void
codeSnippet string
exceptionType string
message string
Результат void
        public static void RunAndGetTheException(
            string codeSnippet, 
            string exceptionType,
            string message)
        {
            //reportRunningCode(codeSnippet);

            try{

                var coll = PSRunner.Runner.RunPSCode(codeSnippet, showCode);
                
                Assert.Fail();
            }
            catch (Exception ee) {

                Assert.AreEqual(exceptionType, ee.GetType().Name);

                if (!ee.Message.Contains(message)) {

                    Assert.Fail("Exception description does not match: " + ee.Message);

                }
            }

            PSRunner.Runner.FinishRunningCode();
        }