Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
test_CommandLineParser.cs1333 linesDownload Raw Back to csharp
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Collections;5using System.Collections.Generic;6using System.Diagnostics;7using System.IO;8using System.Management.Automation;9 10using Microsoft.PowerShell;11using Xunit;12 13namespace PSTests.Parallel14{15    public static class PSCommandLineParserTests16    {17        [Fact]18        public static void TestDefaults()19        {20            var cpp = new CommandLineParameterParser();21 22            cpp.Parse(System.Array.Empty<string>());23 24            Assert.False(cpp.AbortStartup);25            Assert.Empty(cpp.Args);26            Assert.Null(cpp.ConfigurationName);27            Assert.Null(cpp.ConfigurationFile);28            Assert.Null(cpp.CustomPipeName);29            Assert.Null(cpp.ErrorMessage);30            Assert.Null(cpp.ExecutionPolicy);31            Assert.Equal((uint)ConsoleHost.ExitCodeSuccess, cpp.ExitCode);32            Assert.False(cpp.ExplicitReadCommandsFromStdin);33            Assert.Null(cpp.File);34            Assert.Null(cpp.InitialCommand);35            Assert.Equal(Microsoft.PowerShell.Serialization.DataFormat.Text, cpp.InputFormat);36            Assert.False(cpp.NamedPipeServerMode);37            Assert.True(cpp.NoExit);38            Assert.False(cpp.NonInteractive);39            Assert.False(cpp.NoPrompt);40            Assert.Equal(Microsoft.PowerShell.Serialization.DataFormat.Text, cpp.OutputFormat);41            Assert.False(cpp.OutputFormatSpecified);42#if !UNIX43            Assert.False(cpp.RemoveWorkingDirectoryTrailingCharacter);44#endif45            Assert.False(cpp.ServerMode);46            Assert.True(cpp.ShowBanner);47            Assert.False(cpp.ShowShortHelp);48            Assert.False(cpp.ShowVersion);49            Assert.False(cpp.SkipProfiles);50            Assert.False(cpp.SocketServerMode);51#if !UNIX52            Assert.False(cpp.V2SocketServerMode);53#endif54            Assert.False(cpp.SSHServerMode);55            if (Platform.IsWindows)56            {57                Assert.True(cpp.StaMode);58            }59            else60            {61                Assert.False(cpp.StaMode);62            }63 64            Assert.False(cpp.ThrowOnReadAndPrompt);65            Assert.False(cpp.WasInitialCommandEncoded);66            Assert.Null(cpp.WorkingDirectory);67            Assert.False(cpp.NonInteractive);68        }69 70        [Fact]71        public static void Test_Throws_On_Reuse()72        {73            var cpp = new CommandLineParameterParser();74 75            cpp.Parse(System.Array.Empty<string>());76 77            Assert.Throws<System.InvalidOperationException>(() => cpp.Parse(System.Array.Empty<string>()));78        }79 80        [Theory]81        [InlineData("arg1", null, "arg3")]82        public static void Test_ARGS_With_Null(params string[] commandLine)83        {84            var cpp = new CommandLineParameterParser();85 86            Assert.Throws<System.ArgumentNullException>(() => cpp.Parse(commandLine));87        }88 89        [Theory]90        [InlineData("noexistfilename")]91        public static void TestDefaultParameterIsFileName_Not_Exist(params string[] commandLine)92        {93            var cpp = new CommandLineParameterParser();94 95            cpp.Parse(commandLine);96 97            Assert.True(cpp.AbortStartup);98            Assert.False(cpp.NoExit);99            Assert.True(cpp.ShowShortHelp);100            Assert.False(cpp.ShowBanner);101            Assert.Equal(CommandLineParameterParser.NormalizeFilePath("noexistfilename"), cpp.File);102            Assert.Equal(103                string.Format(CommandLineParameterParserStrings.ArgumentFileDoesNotExist, "noexistfilename"),104                cpp.ErrorMessage);105        }106 107        [Fact]108        public static void TestDefaultParameterIsFileName_Exist()109        {110            var tempFile = System.IO.Path.GetTempFileName();111            var tempPs1 = tempFile + ".ps1";112            File.Move(tempFile, tempPs1);113 114            var cpp = new CommandLineParameterParser();115 116            cpp.Parse(new string[] { tempPs1 });117 118            try119            {120                Assert.False(cpp.AbortStartup);121                Assert.False(cpp.NoExit);122                Assert.False(cpp.ShowShortHelp);123                Assert.False(cpp.ShowBanner);124                Assert.Equal(CommandLineParameterParser.NormalizeFilePath(tempPs1), cpp.File);125                Assert.Null(cpp.ErrorMessage);126            }127            finally128            {129                File.Delete(tempPs1);130            }131        }132 133        [Theory]134        [InlineData("-file", "-")]135        public static void TestParameterIsFileName_Dash(params string[] commandLine)136        {137            var cpp = new CommandLineParameterParser();138 139            cpp.Parse(commandLine);140 141            Assert.False(cpp.AbortStartup);142            Assert.True(cpp.NoExit);143            Assert.False(cpp.ShowShortHelp);144            Assert.False(cpp.ShowBanner);145            Assert.False(cpp.NoPrompt);146            Assert.True(cpp.ExplicitReadCommandsFromStdin);147            Assert.Null(cpp.ErrorMessage);148        }149 150        [Theory]151        [InlineData("-prof")]152        public static void TestParameterIs_Wrong_Value(params string[] commandLine)153        {154            var cpp = new CommandLineParameterParser();155 156            cpp.Parse(commandLine);157 158            Assert.True(cpp.AbortStartup);159            Assert.False(cpp.NoExit);160            Assert.False(cpp.ShowShortHelp);161            Assert.False(cpp.ShowBanner);162            Assert.False(cpp.NoPrompt);163            Assert.Contains(commandLine[0], cpp.ErrorMessage);164            Assert.Contains("-noprofile", cpp.ErrorMessage);165        }166 167        [Theory]168        [InlineData("-Version")]169        [InlineData("--Version")]170        [InlineData("/Version")]171        public static void TestParameter_Dash_Or_Slash(params string[] commandLine)172        {173            var cpp = new CommandLineParameterParser();174 175            cpp.Parse(commandLine);176 177            Assert.False(cpp.AbortStartup);178            Assert.False(cpp.NoExit);179            Assert.True(cpp.NonInteractive);180            Assert.False(cpp.ShowBanner);181            Assert.False(cpp.ShowShortHelp);182            Assert.False(cpp.NoPrompt);183            Assert.True(cpp.ShowVersion);184            Assert.True(cpp.SkipProfiles);185            Assert.Null(cpp.ErrorMessage);186        }187 188        [Theory]189        [InlineData("/-Version")]190        [InlineData("-/Version")]191        public static void TestParameter_Wrong_Dash_And_Slash(params string[] commandLine)192        {193            var cpp = new CommandLineParameterParser();194 195            cpp.Parse(commandLine);196 197            Assert.True(cpp.AbortStartup);198            Assert.False(cpp.NoExit);199            Assert.False(cpp.NonInteractive);200            Assert.False(cpp.ShowBanner);201            Assert.True(cpp.ShowShortHelp);202            Assert.False(cpp.NoPrompt);203            Assert.False(cpp.ShowVersion);204            Assert.False(cpp.SkipProfiles);205            Assert.Contains(commandLine[0], cpp.ErrorMessage);206        }207 208        [Theory]209        [InlineData("-Version")]210        [InlineData("-V")]211        [InlineData("-Version", "abbra")] // Ignore all after the parameter212        public static void TestParameter_Version(params string[] commandLine)213        {214            var cpp = new CommandLineParameterParser();215 216            cpp.Parse(commandLine);217 218            Assert.False(cpp.AbortStartup);219            Assert.False(cpp.NoExit);220            Assert.True(cpp.NonInteractive);221            Assert.False(cpp.ShowBanner);222            Assert.True(cpp.ShowVersion);223            Assert.True(cpp.SkipProfiles);224            Assert.Null(cpp.ErrorMessage);225        }226 227        [Theory]228        [InlineData("-Help")]229        [InlineData("-h")]230        public static void TestParameter_Help(params string[] commandLine)231        {232            var cpp = new CommandLineParameterParser();233 234            cpp.Parse(commandLine);235 236            Assert.True(cpp.AbortStartup);237            Assert.True(cpp.ShowShortHelp);238            Assert.True(cpp.ShowExtendedHelp);239            Assert.Null(cpp.ErrorMessage);240        }241 242        [Theory]243        [InlineData("-Login")]244        [InlineData("-l")]245        public static void TestParameter_Login(params string[] commandLine)246        {247            var cpp = new CommandLineParameterParser();248 249            cpp.Parse(commandLine);250 251            // Parser does not change any internal properties for the parameter.252            Assert.False(cpp.AbortStartup);253            Assert.True(cpp.NoExit);254            Assert.False(cpp.ShowShortHelp);255            Assert.True(cpp.ShowBanner);256            Assert.Null(cpp.ErrorMessage);257        }258 259        [Theory]260        [InlineData("-noexit")]261        [InlineData("-noe")]262        public static void TestParameter_NoExit(params string[] commandLine)263        {264            var cpp = new CommandLineParameterParser();265 266            cpp.Parse(commandLine);267 268            Assert.False(cpp.AbortStartup);269            Assert.True(cpp.NoExit);270            Assert.False(cpp.ShowShortHelp);271            Assert.True(cpp.ShowBanner);272            Assert.Null(cpp.ErrorMessage);273        }274 275        [Theory]276        [InlineData("-noprofile")]277        [InlineData("-nop")]278        public static void TestParameter_NoProfile(params string[] commandLine)279        {280            var cpp = new CommandLineParameterParser();281 282            cpp.Parse(commandLine);283 284            Assert.False(cpp.AbortStartup);285            Assert.True(cpp.NoExit);286            Assert.False(cpp.ShowShortHelp);287            Assert.True(cpp.ShowBanner);288            Assert.True(cpp.SkipProfiles);289            Assert.Null(cpp.ErrorMessage);290        }291 292        [Theory]293        [InlineData("-nologo")]294        [InlineData("-nol")]295        public static void TestParameter_NoLogo(params string[] commandLine)296        {297            var cpp = new CommandLineParameterParser();298 299            cpp.Parse(commandLine);300 301            Assert.False(cpp.AbortStartup);302            Assert.True(cpp.NoExit);303            Assert.False(cpp.ShowShortHelp);304            Assert.False(cpp.ShowBanner);305            Assert.Null(cpp.ErrorMessage);306        }307 308        [Theory]309        [InlineData("-noninteractive")]310        [InlineData("-noni")]311        public static void TestParameter_NoInteractive(params string[] commandLine)312        {313            var cpp = new CommandLineParameterParser();314 315            cpp.Parse(commandLine);316 317            Assert.False(cpp.AbortStartup);318            Assert.True(cpp.NoExit);319            Assert.False(cpp.ShowShortHelp);320            Assert.True(cpp.ShowBanner);321            Assert.True(cpp.NonInteractive);322            Assert.Null(cpp.ErrorMessage);323        }324 325        [Theory]326        [InlineData("-socketservermode")]327        [InlineData("-so")]328        public static void TestParameter_SocketServerMode(params string[] commandLine)329        {330            var cpp = new CommandLineParameterParser();331 332            cpp.Parse(commandLine);333 334            Assert.False(cpp.AbortStartup);335            Assert.True(cpp.NoExit);336            Assert.False(cpp.ShowShortHelp);337            Assert.False(cpp.ShowBanner);338            Assert.True(cpp.SocketServerMode);339            Assert.Null(cpp.ErrorMessage);340        }341 342#if !UNIX343        [Theory]344        [InlineData("-v2socketservermode", "-token", "natoheusatoehusnatoeu", "-utctimestamp", "2023-10-01T12:00:00Z")]345        [InlineData("-v2so", "-token", "asentuhasoneuthsaoe", "-utctimestamp", "2025-06-09T12:00:00Z")]346        public static void TestParameter_V2SocketServerMode(params string[] commandLine)347        {348            var cpp = new CommandLineParameterParser();349 350            cpp.Parse(commandLine);351 352            Assert.False(cpp.AbortStartup);353            Assert.True(cpp.NoExit);354            Assert.False(cpp.ShowShortHelp);355            Assert.False(cpp.ShowBanner);356            Assert.True(cpp.V2SocketServerMode);357            Assert.Null(cpp.ErrorMessage);358        }359#endif360 361        [Theory]362        [InlineData("-servermode")]363        [InlineData("-s")]364        public static void TestParameter_ServerMode(params string[] commandLine)365        {366            var cpp = new CommandLineParameterParser();367 368            cpp.Parse(commandLine);369 370            Assert.False(cpp.AbortStartup);371            Assert.True(cpp.NoExit);372            Assert.False(cpp.ShowShortHelp);373            Assert.False(cpp.ShowBanner);374            Assert.True(cpp.ServerMode);375            Assert.Null(cpp.ErrorMessage);376        }377 378        [Theory]379        [InlineData("-namedpipeservermode")]380        [InlineData("-nam")]381        public static void TestParameter_NamedPipeServerMode(params string[] commandLine)382        {383            var cpp = new CommandLineParameterParser();384 385            cpp.Parse(commandLine);386 387            Assert.False(cpp.AbortStartup);388            Assert.True(cpp.NoExit);389            Assert.False(cpp.ShowShortHelp);390            Assert.False(cpp.ShowBanner);391            Assert.True(cpp.NamedPipeServerMode);392            Assert.Null(cpp.ErrorMessage);393        }394 395        [Theory]396        [InlineData("-sshservermode")]397        [InlineData("-sshs")]398        public static void TestParameter_SSHServerMode(params string[] commandLine)399        {400            var cpp = new CommandLineParameterParser();401 402            cpp.Parse(commandLine);403 404            Assert.False(cpp.AbortStartup);405            Assert.True(cpp.NoExit);406            Assert.False(cpp.ShowShortHelp);407            Assert.False(cpp.ShowBanner);408            Assert.True(cpp.SSHServerMode);409            Assert.Null(cpp.ErrorMessage);410        }411 412        [Theory]413        [InlineData("-interactive")]414        [InlineData("-i")]415        public static void TestParameter_Interactive(params string[] commandLine)416        {417            var cpp = new CommandLineParameterParser();418 419            cpp.Parse(commandLine);420 421            Assert.False(cpp.AbortStartup);422            Assert.True(cpp.NoExit);423            Assert.False(cpp.ShowShortHelp);424            Assert.True(cpp.ShowBanner);425            Assert.False(cpp.NonInteractive);426            Assert.Null(cpp.ErrorMessage);427        }428 429        [Theory]430        [InlineData("-configurationname")]431        [InlineData("-config")]432        public static void TestParameter_ConfigurationName_No_Name(params string[] commandLine)433        {434            var cpp = new CommandLineParameterParser();435 436            cpp.Parse(commandLine);437 438            Assert.True(cpp.AbortStartup);439            Assert.True(cpp.NoExit);440            Assert.False(cpp.ShowShortHelp);441            Assert.False(cpp.ShowBanner);442            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);443            Assert.Equal(CommandLineParameterParserStrings.MissingConfigurationNameArgument, cpp.ErrorMessage);444        }445 446        [Theory]447        [InlineData("-configurationname", "qwerty")]448        [InlineData("-config", "qwerty")]449        public static void TestParameter_ConfigurationName_With_Name(params string[] commandLine)450        {451            var cpp = new CommandLineParameterParser();452 453            cpp.Parse(commandLine);454 455            Assert.False(cpp.AbortStartup);456            Assert.True(cpp.NoExit);457            Assert.False(cpp.ShowShortHelp);458            Assert.True(cpp.ShowBanner);459            Assert.Equal("qwerty", cpp.ConfigurationName);460            Assert.Null(cpp.ErrorMessage);461        }462 463        [Theory]464        [InlineData("-configurationfile")]465        public static void TestParameter_ConfigurationFile_No_Name(params string[] commandLine)466        {467            var cpp = new CommandLineParameterParser();468 469            cpp.Parse(commandLine);470 471            Assert.True(cpp.AbortStartup);472            Assert.True(cpp.NoExit);473            Assert.False(cpp.ShowShortHelp);474            Assert.False(cpp.ShowBanner);475            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);476            Assert.Equal(CommandLineParameterParserStrings.MissingConfigurationFileArgument, cpp.ErrorMessage);477        }478 479        [Theory]480        [InlineData("-configurationfile", "qwerty")]481        public static void TestParameter_ConfigurationFile_With_Name(params string[] commandLine)482        {483            var cpp = new CommandLineParameterParser();484 485            cpp.Parse(commandLine);486 487            Assert.False(cpp.AbortStartup);488            Assert.True(cpp.NoExit);489            Assert.False(cpp.ShowShortHelp);490            Assert.True(cpp.ShowBanner);491            Assert.Equal("qwerty", cpp.ConfigurationFile);492            Assert.Null(cpp.ErrorMessage);493        }494 495        [Theory]496        [InlineData("-custompipename")]497        [InlineData("-cus")]498        public static void TestParameter_CustomPipeName_No_Name(params string[] commandLine)499        {500            var cpp = new CommandLineParameterParser();501 502            cpp.Parse(commandLine);503 504            Assert.True(cpp.AbortStartup);505            Assert.True(cpp.NoExit);506            Assert.False(cpp.ShowShortHelp);507            Assert.False(cpp.ShowBanner);508            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);509            Assert.Equal(CommandLineParameterParserStrings.MissingCustomPipeNameArgument, cpp.ErrorMessage);510        }511 512        [Theory]513        [InlineData("-custompipename", "qwerty")]514        [InlineData("-cus", "qwerty")]515        public static void TestParameter_CustomPipeName_With_Name(params string[] commandLine)516        {517            var cpp = new CommandLineParameterParser();518 519            cpp.Parse(commandLine);520 521            Assert.False(cpp.AbortStartup);522            Assert.True(cpp.NoExit);523            Assert.False(cpp.ShowShortHelp);524            Assert.True(cpp.ShowBanner);525            Assert.Equal("qwerty", cpp.CustomPipeName);526            Assert.Null(cpp.ErrorMessage);527        }528 529        public static System.Collections.Generic.IEnumerable<object[]> Data =>530            new System.Collections.Generic.List<string[]>531            {532                new string[] { "-custompipename", new string('q', CommandLineParameterParser.MaxNameLength() + 1) }533            };534 535        [SkippableTheory]536        [MemberData(nameof(Data))]537        public static void TestParameter_CustomPipeName_With_Too_Long_Name(params string[] commandLine)538        {539            Skip.If(Platform.IsWindows);540 541            var cpp = new CommandLineParameterParser();542 543            cpp.Parse(commandLine);544 545            Assert.True(cpp.AbortStartup);546            Assert.True(cpp.NoExit);547            Assert.False(cpp.ShowShortHelp);548            Assert.False(cpp.ShowBanner);549            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);550            Assert.Equal(551                string.Format(552                    CommandLineParameterParserStrings.CustomPipeNameTooLong,553                    CommandLineParameterParser.MaxNameLength(),554                    commandLine[1],555                    commandLine[1].Length),556                cpp.ErrorMessage);557        }558 559        [Theory]560        [InlineData("-command")]561        [InlineData("-c")]562        public static void TestParameter_Command_No_Value(params string[] commandLine)563        {564            var cpp = new CommandLineParameterParser();565 566            cpp.Parse(commandLine);567 568            Assert.True(cpp.AbortStartup);569            Assert.True(cpp.NoExit);570            Assert.True(cpp.ShowShortHelp);571            Assert.False(cpp.ShowBanner);572            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);573            Assert.Equal(CommandLineParameterParserStrings.MissingCommandParameter, cpp.ErrorMessage);574        }575 576        [Theory]577        [InlineData("-command", "qwerty")]578        [InlineData("-c", "qwerty")]579        public static void TestParameter_Command_With_Value(params string[] commandLine)580        {581            var cpp = new CommandLineParameterParser();582 583            cpp.Parse(commandLine);584 585            Assert.False(cpp.AbortStartup);586            Assert.False(cpp.NoExit);587            Assert.False(cpp.ShowShortHelp);588            Assert.False(cpp.ShowBanner);589            Assert.Equal("qwerty", cpp.InitialCommand);590            Assert.Null(cpp.ErrorMessage);591        }592 593        [Theory]594        [InlineData("-command", "-")]595        [InlineData("-c", "-")]596        public static void TestParameter_Command_With_Dash_And_Not_ConsoleInputRedirected(params string[] commandLine)597        {598            var cpp = new CommandLineParameterParser();599 600            cpp.InputRedirectedTestHook = false;601 602            cpp.Parse(commandLine);603 604            Assert.True(cpp.AbortStartup);605            Assert.True(cpp.NoExit);606            Assert.True(cpp.ShowShortHelp);607            Assert.False(cpp.ShowBanner);608            Assert.True(cpp.NoPrompt);609            Assert.True(cpp.ExplicitReadCommandsFromStdin);610            Assert.Equal(CommandLineParameterParserStrings.StdinNotRedirected, cpp.ErrorMessage);611        }612 613        [Theory]614        [InlineData("-command", "-", "abbra")]615        [InlineData("-c", "-", "abbra")]616        public static void TestParameter_Command_With_Dash_And_Tail(params string[] commandLine)617        {618            var cpp = new CommandLineParameterParser();619 620            cpp.Parse(commandLine);621 622            Assert.True(cpp.AbortStartup);623            Assert.True(cpp.NoExit);624            Assert.True(cpp.ShowShortHelp);625            Assert.False(cpp.ShowBanner);626            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);627            Assert.Equal(CommandLineParameterParserStrings.TooManyParametersToCommand, cpp.ErrorMessage);628        }629 630        [Theory]631        [InlineData("-command", "-")]632        [InlineData("-c", "-")]633        public static void TestParameter_Command_With_Dash_And_ConsoleInputRedirected(params string[] commandLine)634        {635            var cpp = new CommandLineParameterParser();636 637            cpp.InputRedirectedTestHook = true;638 639            cpp.Parse(commandLine);640 641            Assert.False(cpp.AbortStartup);642            Assert.True(cpp.NoExit);643            Assert.False(cpp.ShowShortHelp);644            Assert.False(cpp.ShowBanner);645            Assert.Equal((uint)ConsoleHost.ExitCodeSuccess, cpp.ExitCode);646            Assert.True(cpp.ExplicitReadCommandsFromStdin);647            Assert.Null(cpp.ErrorMessage);648        }649 650        [SkippableTheory]651        [InlineData("-windowstyle")]652        [InlineData("-w")]653        public static void TestParameter_WindowsStyle_On_Unix(params string[] commandLine)654        {655            Skip.If(Platform.IsWindows);656 657            var cpp = new CommandLineParameterParser();658 659            cpp.Parse(commandLine);660 661            Assert.True(cpp.AbortStartup);662            Assert.True(cpp.NoExit);663            Assert.False(cpp.ShowShortHelp);664            Assert.False(cpp.ShowBanner);665            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);666            Assert.Equal(CommandLineParameterParserStrings.WindowStyleArgumentNotImplemented, cpp.ErrorMessage);667        }668 669        [SkippableTheory]670        [InlineData("-windowstyle")]671        [InlineData("-w")]672        public static void TestParameter_WindowsStyle_No_Value(params string[] commandLine)673        {674            Skip.IfNot(Platform.IsWindows);675 676            var cpp = new CommandLineParameterParser();677 678            cpp.Parse(commandLine);679 680            Assert.True(cpp.AbortStartup);681            Assert.True(cpp.NoExit);682            Assert.False(cpp.ShowShortHelp);683            Assert.False(cpp.ShowBanner);684            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);685            Assert.Equal(CommandLineParameterParserStrings.MissingWindowStyleArgument, cpp.ErrorMessage);686        }687 688        [SkippableTheory]689        [InlineData("-windowstyle", "abbra")]690        [InlineData("-w", "abbra")]691        public static void TestParameter_WindowsStyle_With_Wrong_Value(params string[] commandLine)692        {693            Skip.IfNot(Platform.IsWindows);694 695            string errorMessage = null;696            try697            {698                ProcessWindowStyle style = (ProcessWindowStyle)LanguagePrimitives.ConvertTo(699                    commandLine[1], typeof(ProcessWindowStyle), System.Globalization.CultureInfo.InvariantCulture);700            }701            catch (PSInvalidCastException e)702            {703                errorMessage = e.Message;704            }705 706            var cpp = new CommandLineParameterParser();707 708            cpp.Parse(commandLine);709 710            Assert.True(cpp.AbortStartup);711            Assert.True(cpp.NoExit);712            Assert.False(cpp.ShowShortHelp);713            Assert.False(cpp.ShowBanner);714            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);715            Assert.Equal(716                string.Format(CommandLineParameterParserStrings.InvalidWindowStyleArgument, commandLine[1], errorMessage),717                cpp.ErrorMessage);718        }719 720        [SkippableTheory]721        [InlineData("-windowstyle", "Maximized")]722        [InlineData("-w", "Maximized")]723        public static void TestParameter_WindowsStyle_With_Right_Value(params string[] commandLine)724        {725            Skip.IfNot(Platform.IsWindows);726 727            var cpp = new CommandLineParameterParser();728 729            cpp.Parse(commandLine);730 731            Assert.False(cpp.AbortStartup);732            Assert.True(cpp.NoExit);733            Assert.False(cpp.ShowShortHelp);734            Assert.True(cpp.ShowBanner);735            Assert.Equal((uint)ConsoleHost.ExitCodeSuccess, cpp.ExitCode);736            Assert.Null(cpp.ErrorMessage);737        }738 739        [Theory]740        [InlineData("-outputformat")]741        [InlineData("-o")]742        [InlineData("-of")]743        public static void TestParameter_OutputFormat_No_Value(params string[] commandLine)744        {745            var index = CommandLineParameterParserStrings.MissingOutputFormatParameter.IndexOf('.');746            var errorMessage = CommandLineParameterParserStrings.MissingOutputFormatParameter.Substring(0, index);747 748            var cpp = new CommandLineParameterParser();749 750            cpp.Parse(commandLine);751 752            Assert.True(cpp.AbortStartup);753            Assert.True(cpp.NoExit);754            Assert.True(cpp.ShowShortHelp);755            Assert.False(cpp.ShowBanner);756            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);757            Assert.Equal(errorMessage, cpp.ErrorMessage.Substring(0, index));758        }759 760        [Theory]761        [InlineData("-outputformat", "abbra")]762        [InlineData("-o", "abbra")]763        [InlineData("-of", "abbra")]764        public static void TestParameter_OutputFormat_With_Wrong_Value(params string[] commandLine)765        {766            var index = CommandLineParameterParserStrings.BadFormatParameterValue.IndexOf('.');767            var errorMessage = CommandLineParameterParserStrings.BadFormatParameterValue.Substring(0, index);768 769            var cpp = new CommandLineParameterParser();770 771            cpp.Parse(commandLine);772 773            Assert.True(cpp.AbortStartup);774            Assert.True(cpp.NoExit);775            Assert.True(cpp.ShowShortHelp);776            Assert.False(cpp.ShowBanner);777            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);778            Assert.Equal(errorMessage, cpp.ErrorMessage.Substring(0, index));779        }780 781        [Theory]782        [InlineData("-outputformat", "XML")]783        [InlineData("-o", "XML")]784        [InlineData("-of", "XML")]785        public static void TestParameter_OutputFormat_With_Right_Value(params string[] commandLine)786        {787            var cpp = new CommandLineParameterParser();788 789            cpp.Parse(commandLine);790 791            Assert.False(cpp.AbortStartup);792            Assert.True(cpp.NoExit);793            Assert.False(cpp.ShowShortHelp);794            Assert.True(cpp.ShowBanner);795            Assert.Equal(Microsoft.PowerShell.Serialization.DataFormat.XML, cpp.OutputFormat);796            Assert.Equal((uint)ConsoleHost.ExitCodeSuccess, cpp.ExitCode);797            Assert.Null(cpp.ErrorMessage);798        }799 800        [Theory]801        [InlineData("-inputformat")]802        [InlineData("-inp")]803        [InlineData("-if")]804        public static void TestParameter_InputFormat_No_Value(params string[] commandLine)805        {806            var index = CommandLineParameterParserStrings.MissingInputFormatParameter.IndexOf('.');807            var errorMessage = CommandLineParameterParserStrings.MissingInputFormatParameter.Substring(0, index);808 809            var cpp = new CommandLineParameterParser();810 811            cpp.Parse(commandLine);812 813            Assert.True(cpp.AbortStartup);814            Assert.True(cpp.NoExit);815            Assert.True(cpp.ShowShortHelp);816            Assert.False(cpp.ShowBanner);817            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);818            Assert.Equal(errorMessage, cpp.ErrorMessage.Substring(0, index));819        }820 821        [Theory]822        [InlineData("-inputformat", "abbra")]823        [InlineData("-inp", "abbra")]824        [InlineData("-if", "abbra")]825        public static void TestParameter_InputFormat_With_Wrong_Value(params string[] commandLine)826        {827            var index = CommandLineParameterParserStrings.BadFormatParameterValue.IndexOf('.');828            var errorMessage = CommandLineParameterParserStrings.BadFormatParameterValue.Substring(0, index);829 830            var cpp = new CommandLineParameterParser();831 832            cpp.Parse(commandLine);833 834            Assert.True(cpp.AbortStartup);835            Assert.True(cpp.NoExit);836            Assert.True(cpp.ShowShortHelp);837            Assert.False(cpp.ShowBanner);838            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);839            Assert.Equal(errorMessage, cpp.ErrorMessage.Substring(0, index));840        }841 842        [Theory]843        [InlineData("-inputformat", "XML")]844        [InlineData("-inp", "XML")]845        [InlineData("-if", "XML")]846        public static void TestParameter_InputFormat_With_Right_Value(params string[] commandLine)847        {848            var cpp = new CommandLineParameterParser();849 850            cpp.Parse(commandLine);851 852            Assert.Equal(commandLine[1], cpp.InputFormat.ToString());853            Assert.False(cpp.AbortStartup);854            Assert.True(cpp.NoExit);855            Assert.False(cpp.ShowShortHelp);856            Assert.True(cpp.ShowBanner);857            Assert.Equal(Microsoft.PowerShell.Serialization.DataFormat.XML, cpp.InputFormat);858            Assert.Equal((uint)ConsoleHost.ExitCodeSuccess, cpp.ExitCode);859            Assert.Null(cpp.ErrorMessage);860        }861 862        [Theory]863        [InlineData("-executionpolicy")]864        [InlineData("-ex")]865        [InlineData("-ep")]866        public static void TestParameter_ExecutionPolicy_No_Value(params string[] commandLine)867        {868            var cpp = new CommandLineParameterParser();869 870            cpp.Parse(commandLine);871 872            Assert.True(cpp.AbortStartup);873            Assert.True(cpp.NoExit);874            Assert.True(cpp.ShowShortHelp);875            Assert.False(cpp.ShowBanner);876            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);877            Assert.Equal(CommandLineParameterParserStrings.MissingExecutionPolicyParameter, cpp.ErrorMessage);878        }879 880        [Theory]881        [InlineData("-executionpolicy", "InvalidPolicy")]882        [InlineData("-ex", "InvalidPolicy")]883        [InlineData("-ep", "InvalidPolicy")]884        public static void TestParameter_ExecutionPolicy_With_Wrong_Value(params string[] commandLine)885        {886            var cpp = new CommandLineParameterParser();887 888            cpp.Parse(commandLine);889 890            Assert.True(cpp.AbortStartup);891            Assert.True(cpp.NoExit);892            Assert.True(cpp.ShowShortHelp);893            Assert.False(cpp.ShowBanner);894            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);895            Assert.Equal(commandLine[1], cpp.ExecutionPolicy);896            Assert.Equal(897                string.Format(CommandLineParameterParserStrings.InvalidExecutionPolicyArgument, "InvalidPolicy"),898                cpp.ErrorMessage);899        }900 901        [Theory]902        [InlineData("-encodedcommand")]903        [InlineData("-e")]904        [InlineData("-ec")]905        public static void TestParameter_EncodedCommand_No_Value(params string[] commandLine)906        {907            var cpp = new CommandLineParameterParser();908 909            cpp.Parse(commandLine);910 911            Assert.True(cpp.AbortStartup);912            Assert.True(cpp.NoExit);913            Assert.True(cpp.ShowShortHelp);914            Assert.False(cpp.ShowBanner);915            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);916            Assert.Equal(CommandLineParameterParserStrings.MissingCommandParameter, cpp.ErrorMessage);917        }918 919        [Theory]920        [InlineData("-encodedcommand", "YQBiAGIAcgBhAA==")] // 'abbra' in Base64 format921        [InlineData("-e", "YQBiAGIAcgBhAA==")]922        [InlineData("-ec", "YQBiAGIAcgBhAA==")]923        public static void TestParameter_EncodedCommand_With_Value(params string[] commandLine)924        {925            var cpp = new CommandLineParameterParser();926 927            cpp.Parse(commandLine);928 929            Assert.False(cpp.AbortStartup);930            Assert.False(cpp.NoExit);931            Assert.False(cpp.ShowShortHelp);932            Assert.False(cpp.ShowBanner);933            Assert.Equal("abbra", cpp.InitialCommand);934            Assert.Null(cpp.ErrorMessage);935        }936 937        [Theory]938        [InlineData("-encodedcommand", "-")]939        [InlineData("-e", "-")]940        [InlineData("-ec", "-")]941        public static void TestParameter_EncodedCommand_With_Dash(params string[] commandLine)942        {943            var cpp = new CommandLineParameterParser();944 945            cpp.Parse(commandLine);946 947            Assert.True(cpp.AbortStartup);948            Assert.True(cpp.NoExit);949            Assert.True(cpp.ShowShortHelp);950            Assert.False(cpp.ShowBanner);951            Assert.False(cpp.NoPrompt);952            Assert.False(cpp.ExplicitReadCommandsFromStdin);953            Assert.Equal(CommandLineParameterParserStrings.BadCommandValue, cpp.ErrorMessage);954        }955 956        [Theory]957        [InlineData("-encodedcommand", "-", "YQBiAGIAcgBhAA==")]958        [InlineData("-e", "-", "YQBiAGIAcgBhAA==")]959        [InlineData("-ec", "-", "YQBiAGIAcgBhAA==")]960        public static void TestParameter_EncodedCommand_With_Dash_And_Tail(params string[] commandLine)961        {962            var cpp = new CommandLineParameterParser();963 964            cpp.Parse(commandLine);965 966            Assert.True(cpp.AbortStartup);967            Assert.True(cpp.NoExit);968            Assert.True(cpp.ShowShortHelp);969            Assert.False(cpp.ShowBanner);970            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);971            Assert.Equal(CommandLineParameterParserStrings.BadCommandValue, cpp.ErrorMessage);972        }973 974        [Theory]975        [InlineData("-encodedcommand", "-")]976        [InlineData("-e", "-")]977        [InlineData("-ec", "-")]978        public static void TestParameter_EncodedCommand_With_Dash_And_ConsoleInputRedirected(params string[] commandLine)979        {980            var cpp = new CommandLineParameterParser();981 982            cpp.InputRedirectedTestHook = true;983 984            cpp.Parse(commandLine);985 986            Assert.True(cpp.AbortStartup);987            Assert.True(cpp.NoExit);988            Assert.True(cpp.ShowShortHelp);989            Assert.False(cpp.ShowBanner);990            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);991            Assert.False(cpp.ExplicitReadCommandsFromStdin);992            Assert.Equal(CommandLineParameterParserStrings.BadCommandValue, cpp.ErrorMessage);993        }994 995        [Theory]996        [InlineData("-encodedarguments")]997        [InlineData("-encodeda")]998        [InlineData("-ea")]999        public static void TestParameter_EncodedArguments_No_Value(params string[] commandLine)1000        {1001            var cpp = new CommandLineParameterParser();1002 1003            cpp.Parse(commandLine);1004 1005            Assert.True(cpp.AbortStartup);1006            Assert.True(cpp.NoExit);1007            Assert.True(cpp.ShowShortHelp);1008            Assert.False(cpp.ShowBanner);1009            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);1010            Assert.Equal(CommandLineParameterParserStrings.MissingArgsValue, cpp.ErrorMessage);1011        }1012 1013        [Theory]1014        [InlineData("-encodedarguments", "abbra")]1015        [InlineData("-encodeda", "abbra")]1016        [InlineData("-ea", "abbra")]1017        public static void TestParameter_EncodedArguments_With_Wrong_Value(params string[] commandLine)1018        {1019            var cpp = new CommandLineParameterParser();1020 1021            cpp.Parse(commandLine);1022 1023            Assert.True(cpp.AbortStartup);1024            Assert.True(cpp.NoExit);1025            Assert.True(cpp.ShowShortHelp);1026            Assert.False(cpp.ShowBanner);1027            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);1028            Assert.Equal(CommandLineParameterParserStrings.BadArgsValue, cpp.ErrorMessage);1029        }1030 1031        [Theory]1032        [InlineData("-encodedarguments", "PABPAGIAagBzACAAVgBlAHIAcwBpAG8AbgA9ACIAMQAuADEALgAwAC4AMQAiACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8AcABvAHcAZQByAHMAaABlAGwAbAAvADIAMAAwADQALwAwADQAIgA+AA0ACgAgACAAPABPAGIAagAgAFIAZQBmAEkAZAA9ACIAMAAiAD4ADQAKACAAIAAgACAAPABUAE4AIABSAGUAZgBJAGQAPQAiADAAIgA+AA0ACgAgACAAIAAgACAAIAA8AFQAPgBTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEEAcgByAGEAeQBMAGkAcwB0ADwALwBUAD4ADQAKACAAIAAgACAAIAAgADwAVAA+AFMAeQBzAHQAZQBtAC4ATwBiAGoAZQBjAHQAPAAvAFQAPgANAAoAIAAgACAAIAA8AC8AVABOAD4ADQAKACAAIAAgACAAPABMAFMAVAA+AA0ACgAgACAAIAAgACAAIAA8AFMAPgAtAGEAYgBiAHIAYQA8AC8AUwA+AA0ACgAgACAAIAAgADwALwBMAFMAVAA+AA0ACgAgACAAPAAvAE8AYgBqAD4ADQAKADwALwBPAGIAagBzAD4A")] // '-abbra' in Base64 format1033        [InlineData("-encodeda", "PABPAGIAagBzACAAVgBlAHIAcwBpAG8AbgA9ACIAMQAuADEALgAwAC4AMQAiACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8AcABvAHcAZQByAHMAaABlAGwAbAAvADIAMAAwADQALwAwADQAIgA+AA0ACgAgACAAPABPAGIAagAgAFIAZQBmAEkAZAA9ACIAMAAiAD4ADQAKACAAIAAgACAAPABUAE4AIABSAGUAZgBJAGQAPQAiADAAIgA+AA0ACgAgACAAIAAgACAAIAA8AFQAPgBTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEEAcgByAGEAeQBMAGkAcwB0ADwALwBUAD4ADQAKACAAIAAgACAAIAAgADwAVAA+AFMAeQBzAHQAZQBtAC4ATwBiAGoAZQBjAHQAPAAvAFQAPgANAAoAIAAgACAAIAA8AC8AVABOAD4ADQAKACAAIAAgACAAPABMAFMAVAA+AA0ACgAgACAAIAAgACAAIAA8AFMAPgAtAGEAYgBiAHIAYQA8AC8AUwA+AA0ACgAgACAAIAAgADwALwBMAFMAVAA+AA0ACgAgACAAPAAvAE8AYgBqAD4ADQAKADwALwBPAGIAagBzAD4A")]1034        [InlineData("-ea", "PABPAGIAagBzACAAVgBlAHIAcwBpAG8AbgA9ACIAMQAuADEALgAwAC4AMQAiACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8AcABvAHcAZQByAHMAaABlAGwAbAAvADIAMAAwADQALwAwADQAIgA+AA0ACgAgACAAPABPAGIAagAgAFIAZQBmAEkAZAA9ACIAMAAiAD4ADQAKACAAIAAgACAAPABUAE4AIABSAGUAZgBJAGQAPQAiADAAIgA+AA0ACgAgACAAIAAgACAAIAA8AFQAPgBTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEEAcgByAGEAeQBMAGkAcwB0ADwALwBUAD4ADQAKACAAIAAgACAAIAAgADwAVAA+AFMAeQBzAHQAZQBtAC4ATwBiAGoAZQBjAHQAPAAvAFQAPgANAAoAIAAgACAAIAA8AC8AVABOAD4ADQAKACAAIAAgACAAPABMAFMAVAA+AA0ACgAgACAAIAAgACAAIAA8AFMAPgAtAGEAYgBiAHIAYQA8AC8AUwA+AA0ACgAgACAAIAAgADwALwBMAFMAVAA+AA0ACgAgACAAPAAvAE8AYgBqAD4ADQAKADwALwBPAGIAagBzAD4A")]1035        public static void TestParameter_EncodedArguments_With_Value(params string[] commandLine)1036        {1037            var cpp = new CommandLineParameterParser();1038 1039            cpp.Parse(commandLine);1040 1041            Assert.Null(cpp.ErrorMessage);1042            Assert.False(cpp.AbortStartup);1043            Assert.True(cpp.NoExit);1044            Assert.False(cpp.ShowShortHelp);1045            Assert.True(cpp.ShowBanner);1046            Assert.Equal("-abbra", cpp.Args[0].Value);1047        }1048 1049        [Theory]1050        [InlineData("-settingsfile")]1051        [InlineData("-settings")]1052        public static void TestParameter_SettingsFile_No_Value(params string[] commandLine)1053        {1054            var cpp = new CommandLineParameterParser();1055 1056            cpp.Parse(commandLine);1057 1058            Assert.True(cpp.AbortStartup);1059            Assert.True(cpp.NoExit);1060            Assert.False(cpp.ShowShortHelp);1061            Assert.False(cpp.ShowBanner);1062            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);1063            Assert.Equal(CommandLineParameterParserStrings.MissingSettingsFileArgument, cpp.ErrorMessage);1064        }1065 1066        [Theory]1067        [InlineData("-settingsfile", "noexistfilename")]1068        [InlineData("-settings", "noexistfilename")]1069        public static void TestParameter_SettingsFile_Not_Exists(params string[] commandLine)1070        {1071            var cpp = new CommandLineParameterParser();1072 1073            cpp.Parse(commandLine);1074 1075            Assert.True(cpp.AbortStartup);1076            Assert.True(cpp.NoExit);1077            Assert.False(cpp.ShowShortHelp);1078            Assert.False(cpp.ShowBanner);1079            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);1080            Assert.Equal(1081                string.Format(CommandLineParameterParserStrings.SettingsFileNotExists, Path.GetFullPath("noexistfilename")),1082                cpp.ErrorMessage);1083        }1084 1085        public class TestDataSettingsFile : IEnumerable<object[]>1086        {1087            private readonly string _fileName = Path.GetTempFileName();1088 1089            public IEnumerator<object[]> GetEnumerator()1090            {1091                yield return new object[] { "-settingsfile", _fileName };1092                yield return new object[] { "-settings", _fileName };1093            }1094 1095            IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();1096        }1097 1098        [Theory]1099        [ClassData(typeof(TestDataSettingsFile))]1100        public static void TestParameter_SettingsFile_Exists(params string[] commandLine)1101        {1102            var cpp = new CommandLineParameterParser();1103 1104            cpp.Parse(commandLine);1105 1106            Assert.False(cpp.AbortStartup);1107            Assert.True(cpp.NoExit);1108            Assert.False(cpp.ShowShortHelp);1109            Assert.True(cpp.ShowBanner);1110            Assert.Equal((uint)ConsoleHost.ExitCodeSuccess, cpp.ExitCode);1111            Assert.Null(cpp.ErrorMessage);1112            Assert.Equal(commandLine[1], cpp.SettingsFile);1113        }1114 1115        [SkippableTheory]1116        [InlineData("-sta")]1117        public static void TestParameter_STA_Not_IsWindowsDesktop(params string[] commandLine)1118        {1119            Skip.If(Platform.IsWindowsDesktop);1120 1121            var cpp = new CommandLineParameterParser();1122 1123            cpp.Parse(commandLine);1124 1125            Assert.True(cpp.AbortStartup);1126            Assert.True(cpp.NoExit);1127            Assert.False(cpp.ShowShortHelp);1128            Assert.False(cpp.ShowBanner);1129            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);1130            Assert.Equal(CommandLineParameterParserStrings.STANotImplemented, cpp.ErrorMessage);1131        }1132 1133        [SkippableTheory]1134        [InlineData("-mta", "-sta")]1135        public static void TestParameter_STA_And_MTA_Mutually_Exclusive(params string[] commandLine)1136        {1137            Skip.IfNot(Platform.IsWindows);1138 1139            var cpp = new CommandLineParameterParser();1140 1141            cpp.Parse(commandLine);1142 1143            Assert.True(cpp.AbortStartup);1144            Assert.True(cpp.NoExit);1145            Assert.False(cpp.ShowShortHelp);1146            Assert.False(cpp.ShowBanner);1147            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);1148            Assert.Equal(CommandLineParameterParserStrings.MtaStaMutuallyExclusive, cpp.ErrorMessage);1149        }1150 1151        [SkippableTheory]1152        [InlineData("-sta")]1153        public static void TestParameter_STA(params string[] commandLine)1154        {1155            Skip.IfNot(Platform.IsWindows);1156 1157            var cpp = new CommandLineParameterParser();1158 1159            cpp.Parse(commandLine);1160 1161            Assert.False(cpp.AbortStartup);1162            Assert.True(cpp.NoExit);1163            Assert.False(cpp.ShowShortHelp);1164            Assert.True(cpp.ShowBanner);1165            Assert.True(cpp.StaMode);1166            Assert.Null(cpp.ErrorMessage);1167        }1168 1169        [SkippableTheory]1170        [InlineData("-mta")]1171        public static void TestParameter_MTA_Not_IsWindowsDesktop(params string[] commandLine)1172        {1173            Skip.If(Platform.IsWindowsDesktop);1174 1175            var cpp = new CommandLineParameterParser();1176 1177            cpp.Parse(commandLine);1178 1179            Assert.True(cpp.AbortStartup);1180            Assert.True(cpp.NoExit);1181            Assert.False(cpp.ShowShortHelp);1182            Assert.False(cpp.ShowBanner);1183            Assert.Equal((uint)ConsoleHost.ExitCodeBadCommandLineParameter, cpp.ExitCode);1184            Assert.Equal(CommandLineParameterParserStrings.MTANotImplemented, cpp.ErrorMessage);1185        }1186 1187        [SkippableTheory]1188        [InlineData("-sta", "-mta")]1189        public static void TestParameter_MTA_And_STA_Mutually_Exclusive(params string[] commandLine)1190        {1191            Skip.IfNot(Platform.IsWindows);1192 1193            var cpp = new CommandLineParameterParser();1194 1195            cpp.Parse(commandLine);1196 1197            Assert.True(cpp.AbortStartup);1198            Assert.True(cpp.NoExit);1199            Assert.False(cpp.ShowShortHelp);1200            Assert.False(cpp.ShowBanner);

Showing the first 1,200 of 1333 lines. Download the file for the rest.