Esempio n. 1
0
        internal static Collection <PSObject> InvokeAndAssertForErrors(this System.Management.Automation.PowerShell powershell, string expectedErrorMsg = null)
        {
            powershell.Streams.ClearStreams();
            var result = powershell.Invoke();

            if (string.IsNullOrEmpty(expectedErrorMsg))
            {
                Assert.IsFalse(powershell.HadErrors, powershell.GetPowershellErrorMessage());
            }
            else
            {
                Assert.IsTrue(powershell.HadErrors);
            }

            Assert.AreEqual(expectedErrorMsg, powershell.GetPowershellErrorMessage());
            return(result);
        }