public void IdentifiedArgs_AfterLastArgOfLastSwitch__Is_AddedTo__EndStandAloneArgs() { var testSwitch = new Switch( name: TestSwitchAlphaLf, name1Char: TestSwitchAlphaSf, maxArgs: 0); Switch.AssimilateArgs(args5_ItHasEverything); //If either or both first 2 arguments aren't in List EndStandAloneArgs, then fail test if (Switch.EndStandAloneArgs[0] != args5_ItHasEverything[3] || Switch.EndStandAloneArgs[1] != args5_ItHasEverything[4] ) { Assert.Fail("EndStandAloneArgs does not contain the end-stand-alone args"); } //If List EndStandAloneArgs contains Switch, then fail test if (Switch.StartStandAloneArgs.Contains(TestSwitchAlphaLfpLinux)) { Assert.Fail("EndStandAloneArgs contains a switch"); } //If List EndStandAloneArgs contained anything but the first 2 arguments, then fail test foreach (var arg in Switch.EndStandAloneArgs) { if (arg != args5_ItHasEverything[3] && arg != args5_ItHasEverything[4]) { Assert.Fail("EndStandAloneArgs contains nothing of what it's suppose to have"); } } }
public void ValueOfNullExcludesIt() { var testSwitch = new Switch( name: "test", name1Char: null); var args = new string[] { "-t", "fake arg" }; Switch.AssimilateArgs(args); if (Switch.UsedSwitches.Contains(testSwitch)) { Assert.Fail("When excluding the single-character-name of a switch, the Switch can not be invoked by its short name"); } }
public void LimitsTotalSwitchArgsAccepted() { var testSwitch = new Switch( name: "test", name1Char: "t", maxArgs: 3); var args = new string[] { "--test", "Allies are the undead (God of War), Death Claws (Fallout), and player1 with a nano suit (Crysis; with 2 weapons of choice) ", "Fraction of allies ride into glorious battle on queen Xenomorphs (Alien) equipped with rail guns", "'Environmental hazards' include actively firing imperial-class Star Destroyers (Star Wars; reason: poor aim), Reapers (Mass Effect), dragons (Skyrim), and Tribbles (Star Trek; tripping hazard... or dragon food?)", "'Environmental hazards' include debri -- falling or stationary -- from inevitable intercombat of previously said 'environmental hazards'", "Enemies are demons (Doom), demons (Dragon Age), and player2 as 'the demon' (Halo; with 2 weapons of choice)", "Fraction of enemies ride into glorious battle on Brumaks (Gears of War)", }; Switch.AssimilateArgs(args); if (testSwitch.Args.Count != 3) { Assert.Fail("Switch was not restricted to 3 arguments"); } }
public void IdentifiedSwitches__Are_AddedTo__UsedSwitches() { var testSwitch = new Switch( name: "test", name1Char: "t"); var testSwitch2 = new Switch( name: "box", name1Char: "b"); var testSwitch3 = new Switch( name: "start", name1Char: "s"); Switch.AssimilateArgs(new string[] { "argOrphan", "--test", "argT", "--box", "argB", "--start", "argS" }); if (!(Switch.UsedSwitches.Contains(testSwitch) && Switch.UsedSwitches.Contains(testSwitch2) && Switch.UsedSwitches.Contains(testSwitch3))) { Assert.Fail("Identified Switches from raw arguments were not sent to List UsedSwitches"); } }
public void IdentifiedArgs_NotAccepted_BeforeLastArgOfLastSwitch_IdentifiedArgumentNotAddedToAnyStandAloneList() { var testSwitch1 = new Switch( name: "test", name1Char: "t", maxArgs: 0); var testSwitch2 = new Switch( name: "box", name1Char: "b", maxArgs: 0); string[] args = new string[] { "--test", "orphan1", "orphan2", "--box" }; Switch.AssimilateArgs(args); if (Switch.StartStandAloneArgs.Contains("orphan1") || Switch.StartStandAloneArgs.Contains("orphan2") || Switch.EndStandAloneArgs.Contains("orphan1") || Switch.EndStandAloneArgs.Contains("orphan2")) { Assert.Fail("Nothing was suppose to happen with non-accepted args \"orphan1\" and \"orphan2\", but it ended up in either List StartStandAloneArgs or EndStandAloneArgs"); } }