public DataManager(Game game)
            : base(game)
        {
            _switches  = new SwitchCollection();
            _variables = new VariableCollection();

            _switches["Achievement Test"] = new Switch()
            {
                Name = "Achievement Test"
            };
            _switches["switch_ponies"] = new Switch()
            {
                Name = "Multi Switch Check Test"
            };

            _playerParty      = new BattleDataCollection();
            _playerCharacters = new BattleDataCollection();
            _enemyCollection  = new BattleDataCollection();

            _switches["Achievement Test"].TurnOn();
            PlayerName                  = new Variable("Pinkie Pie");
            PlayerGold                  = new Variable(1000);
            PlayerSteps                 = new Variable(0);
            PlayerName.Value            = "Pinkie Pie";
            _variables["{steps_taken}"] = PlayerSteps;
            _variables["{profilename}"] = PlayerName;
            _variables["{gold}"]        = PlayerGold;
        }
        public DataManager(Game game)
            : base(game)
        {
            _switches = new SwitchCollection();
            _variables = new VariableCollection();
            _achievementsToCreate = new Stack<Achievement>();

            _switches["Achievement Test"] = new Switch()
            {
                Name = "Achievement Test"
            };
            _switches["switch_ponies"] = new Switch()
            {
                Name = "Multi Switch Check Test"
            };

            _switches["Achievement Test"].TurnOn();
            PlayerName = new Variable("Pinkie Pie");
            PlayerGold = new Variable(1000);
            PlayerSteps = new Variable(0);
            PlayerName.Value = "Pinkie Pie";
            _variables["{steps_taken}"] = PlayerSteps;
            _variables["{profilename}"] = PlayerName;
            _variables["{gold}"] = PlayerGold;
        }
        public DataManager(Game game)
            : base(game)
        {
            _switches = new SwitchCollection();
            _variables = new VariableCollection();

            _switches["Achievement Test"] = new Switch()
            {
                Name = "Achievement Test"
            };
            _switches["switch_ponies"] = new Switch()
            {
                Name = "Multi Switch Check Test"
            };

            _playerParty = new BattleDataCollection();
            _playerCharacters = new BattleDataCollection();
            _enemyCollection = new BattleDataCollection();

            _switches["Achievement Test"].TurnOn();
            PlayerName = new Variable("Pinkie Pie");
            PlayerGold = new Variable(1000);
            PlayerSteps = new Variable(0);
            PlayerName.Value = "Pinkie Pie";
            _variables["{steps_taken}"] = PlayerSteps;
            _variables["{profilename}"] = PlayerName;
            _variables["{gold}"] = PlayerGold;
        }
Beispiel #4
0
        public DataManager(Game game)
            : base(game)
        {
            _switches             = new SwitchCollection();
            _variables            = new VariableCollection();
            _achievementsToCreate = new Stack <Achievement>();

            _switches["Achievement Test"] = new Switch()
            {
                Name = "Achievement Test"
            };
            _switches["switch_ponies"] = new Switch()
            {
                Name = "Multi Switch Check Test"
            };

            _switches["Achievement Test"].TurnOn();
            PlayerName                  = new Variable("Pinkie Pie");
            PlayerGold                  = new Variable(1000);
            PlayerSteps                 = new Variable(0);
            PlayerName.Value            = "Pinkie Pie";
            _variables["{steps_taken}"] = PlayerSteps;
            _variables["{profilename}"] = PlayerName;
            _variables["{gold}"]        = PlayerGold;
        }
Beispiel #5
0
        public void TestMethod1()
        {
            DataTable        dt   = GetMockDataTable();
            SwitchCollection coll = new SwitchCollection(dt);

            Assert.AreEqual(6, dt.Rows.Count, "rows count suppose to be 6!");
            Assert.AreEqual(3, coll.Count, string.Format("Number of total switches is {0}, but expected 3!", coll.Count));
            Assert.AreEqual(3, coll[0].ports.Count, string.Format("Number of ports for Switch 192.168.1.1 is {0}, but expected 3!", coll[0].ports.Count));
        }
Beispiel #6
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="arguments">
		/// Array of strings representing command-line arguments.
		/// </param>
		/// <param name="switches">
		/// SwitchCollection representing collection of switches expected to be
		/// parsed from given command-line arguments.
		/// </param>
		public ArgumentParser(string[] arguments, SwitchCollection switches)
		{
			if (arguments == null || switches == null)
				throw new ArgumentNullException();

			m_arguments = arguments;
			m_parsedSwitches = new SwitchCollection();
			m_switches = switches;
		}
Beispiel #7
0
        public MainPage()
        {
            this.InitializeComponent();

            CDNDownloader downloader = new CDNDownloader("client.pfx", "0000000000000000", "5.1.0-0", "lp1");

            gameCollection = new SwitchCollection(downloader);

            gameCollection.LoadTitleKeysFile("titlekeys.txt");
            gameCollection.LoadTitleIcons("Images");
        }
Beispiel #8
0
        /// <summary>
        /// Define expected switches to parse from command-line arguments.
        /// </summary>
        static void DefineSwitches()
        {
            s_switches = new SwitchCollection();

            s_switches.Add(SwitchNames.Help,
                           Resources.HelpSwitchLongName,
                           Resources.HelpSwitchDescription);

            s_switches.Add(SwitchNames.ConfigurationFlags,
                           Resources.ConfigurationFlagsSwitchLongName,
                           Resources.ConfigurationFlagsSwitchDescription,
                           true,
                           false,
                           Resources.ConfigurationFlagsSwitchArgumentName);

            s_switches.Add(SwitchNames.OutputFile,
                           Resources.OutputFileSwitchLongName,
                           Resources.OutputFileSwitchDescription,
                           false,
                           Resources.OutputFileSwitchArgumentName);

            s_switches.Add(SwitchNames.ProjectFiles,
                           Resources.ProjectFilesSwitchLongName,
                           Resources.ProjectFilesSwitchDescription,
                           true,
                           false,
                           Resources.ProjectFilesSwitchArgumentName);

            s_switches.Add(SwitchNames.RecursiveSearch,
                           Resources.RecursiveSearchSwitchLongName,
                           Resources.RecursiveSearchSwitchDescription);

            s_switches.Add(SwitchNames.SettingsFile,
                           Resources.SettingsFileSwitchLongName,
                           Resources.SettingsFileSwitchDescription,
                           false,
                           Resources.SettingsFileSwitchArgumentName);

            s_switches.Add(SwitchNames.SolutionFiles,
                           Resources.SolutionFilesSwitchLongName,
                           Resources.SolutionFilesSwitchDescription,
                           true,
                           false,
                           Resources.SolutionFilesSwitchArgumentName);

            s_switches.Add(SwitchNames.SourceFiles,
                           Resources.SourceFilesSwitchLongName,
                           Resources.SourceFilesSwitchDescription,
                           true,
                           false,
                           Resources.SourceFilesSwitchArgumentName);
        }
Beispiel #9
0
		public void Parse()
		{
			const string Name1 = "arg1";
			const string Name2 = "arg2";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name1),
				Switch.GetPrefixedName(Name2)
			};

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1);
			switches.Add(Name2);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsFalse(parser.IsParsed(EmptyName));
			Assert.IsFalse(parser.IsParsed(Name1));
			Assert.IsFalse(parser.IsParsed(Name2));
			Assert.IsFalse(parser.IsParsed(NoName));
			Assert.IsFalse(m_emptyParser.IsParsed(EmptyName));
			Assert.IsFalse(m_emptyParser.IsParsed(Name1));
			Assert.IsFalse(m_emptyParser.IsParsed(Name2));
			Assert.IsFalse(m_emptyParser.IsParsed(NoName));

			parser.Parse();

			Assert.IsFalse(parser.IsParsed(EmptyName));
			Assert.IsFalse(parser.IsParsed(NoName));

			Assert.IsTrue(parser.IsParsed(Name1));
			Assert.IsTrue(parser.IsParsed(Name2));
		}
Beispiel #10
0
		public void GetValues()
		{
			const string Name1 = "name1";
			const string Name2 = "name2";
			const int NumberArguments = 2;
			const string Value1 = "value1";
			const string Value2 = "value2";
			const string Value3 = "value3";
			const string Value4 = "value4";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name1),
				Value1, Value2,
				Switch.GetPrefixedName(Name2),
				Value3, Value4
			};

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1, NoLongName, NoDescription, NumberArguments, IsRequired);
			switches.Add(Name2, NoLongName, NoDescription, NumberArguments, IsRequired);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsNull(parser.GetValues(EmptyName));
			Assert.IsNull(parser.GetValues(Name1));
			Assert.IsNull(parser.GetValues(Name2));
			Assert.IsNull(parser.GetValues(NoName));
			Assert.IsNull(m_emptyParser.GetValues(EmptyName));
			Assert.IsNull(m_emptyParser.GetValues(Name1));
			Assert.IsNull(m_emptyParser.GetValues(Name2));
			Assert.IsNull(m_emptyParser.GetValues(NoName));

			parser.Parse();

			Assert.AreEqual(new string[] { Value1, Value2 }, parser.GetValues(Name1));
			Assert.AreEqual(new string[] { Value3, Value4 }, parser.GetValues(Name2));

			Assert.IsNull(parser.GetValues(EmptyName));
			Assert.IsNull(parser.GetValues(NoName));
		}
Beispiel #11
0
		public void NoneParsed()
		{
			const string Name1 = "arg1";
			const string Name2 = "arg2";
			const string Name3 = "arg3";
			const string Name4 = "arg4";
			const string Name5 = "arg5";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name1),
				Switch.GetPrefixedName(Name2)
			};

			string[] switchNames1 = new string[] { Name1 };
			string[] switchNames2 = new string[] { Name1, Name2 };
			string[] switchNames3 = new string[] { Name1, Name2, Name3 };
			string[] switchNames4 = new string[] { Name2, Name3, Name4 };
			string[] switchNames5 = new string[] { Name4, Name5 };

			SwitchCollection switches = new SwitchCollection();

			switches.Add(switchNames2);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsTrue(parser.NoneParsed(switchNames1));
			Assert.IsTrue(parser.NoneParsed(switchNames2));
			Assert.IsTrue(parser.NoneParsed(switchNames3));
			Assert.IsTrue(parser.NoneParsed(switchNames4));
			Assert.IsTrue(parser.NoneParsed(switchNames5));
			Assert.IsTrue(m_emptyParser.NoneParsed(switchNames1));
			Assert.IsTrue(m_emptyParser.NoneParsed(switchNames2));
			Assert.IsTrue(m_emptyParser.NoneParsed(switchNames3));

			parser.Parse();

			Assert.IsFalse(parser.NoneParsed(switchNames1));
			Assert.IsFalse(parser.NoneParsed(switchNames2));
			Assert.IsFalse(parser.NoneParsed(switchNames3));
			Assert.IsFalse(parser.NoneParsed(switchNames4));
			
			Assert.IsTrue(parser.NoneParsed(switchNames5));
		}
Beispiel #12
0
		public void GetValue()
		{
			const string ArgumentName1 = "arg1";
			const string ArgumentName2 = "arg2";
			const string Name1 = "name1";
			const string Name2 = "name2";
			const string Value1 = "value1";
			const string Value2 = "value2";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name1),
				Value1,
				Switch.GetPrefixedName(Name2),
				Value2
			};

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1, NoLongName, NoDescription, IsRequired, ArgumentName1);
			switches.Add(Name2, NoLongName, NoDescription, IsRequired, ArgumentName2);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsNull(parser.GetValue(EmptyName));
			Assert.IsNull(parser.GetValue(Name1));
			Assert.IsNull(parser.GetValue(Name2));
			Assert.IsNull(parser.GetValue(NoName));
			Assert.IsNull(m_emptyParser.GetValue(EmptyName));
			Assert.IsNull(m_emptyParser.GetValue(NoName));

			parser.Parse();

			Assert.AreEqual(Value1, parser.GetValue(Name1));
			Assert.AreEqual(Value2, parser.GetValue(Name2));

			Assert.IsNull(parser.GetValue(EmptyName));
			Assert.IsNull(parser.GetValue(NoName));
		}
Beispiel #13
0
		public void GetValueWithInvalidArgumentNumber()
		{
			const int Argument0 = 0;
			const int Argument1 = 1;
			const int Argument2 = 2;
			const string ArgumentName = "arg1";
			const string Name = "name1";
			const string Value = "value1";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name),
				Value
			};

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name, NoLongName, NoDescription, IsRequired, ArgumentName);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsNull(parser.GetValue(EmptyName, Argument0));
			Assert.IsNull(parser.GetValue(EmptyName, Argument1));
			Assert.IsNull(parser.GetValue(EmptyName, Argument2));
			Assert.IsNull(parser.GetValue(Name, Argument0));
			Assert.IsNull(parser.GetValue(Name, Argument1));
			Assert.IsNull(parser.GetValue(Name, Argument2));
			Assert.IsNull(parser.GetValue(NoName, Argument0));
			Assert.IsNull(parser.GetValue(NoName, Argument1));
			Assert.IsNull(parser.GetValue(NoName, Argument2));
			Assert.IsNull(m_emptyParser.GetValue(EmptyName, Argument0));
			Assert.IsNull(m_emptyParser.GetValue(EmptyName, Argument1));
			Assert.IsNull(m_emptyParser.GetValue(EmptyName, Argument2));
			Assert.IsNull(m_emptyParser.GetValue(NoName, Argument0));
			Assert.IsNull(m_emptyParser.GetValue(NoName, Argument1));
			Assert.IsNull(m_emptyParser.GetValue(NoName, Argument2));

			parser.Parse();

			Assert.AreEqual(Value, parser.GetValue(Name, Argument1));

			Assert.IsNull(parser.GetValue(EmptyName, Argument0));
			Assert.IsNull(parser.GetValue(EmptyName, Argument1));
			Assert.IsNull(parser.GetValue(EmptyName, Argument2));
			Assert.IsNull(parser.GetValue(Name, Argument0));
			Assert.IsNull(parser.GetValue(Name, Argument2));
			Assert.IsNull(parser.GetValue(NoName, Argument0));
			Assert.IsNull(parser.GetValue(NoName, Argument1));
			Assert.IsNull(parser.GetValue(NoName, Argument2));
		}
Beispiel #14
0
		public void ParseTwice()
		{
			const string Name1 = "arg1";
			const string Name2 = "arg2";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name1),
				Switch.GetPrefixedName(Name2)
			};

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1);
			switches.Add(Name2);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsFalse(parser.IsParsed(Name1));
			Assert.IsFalse(parser.IsParsed(Name2));

			parser.Parse();

			// No exceptions should be thrown on second successive call.
			Assert.DoesNotThrow(delegate { parser.Parse(); });

			Assert.IsTrue(parser.IsParsed(Name1));
			Assert.IsTrue(parser.IsParsed(Name2));
		}
Beispiel #15
0
		public void Initialize()
		{
			m_switches = new SwitchCollection();
		}
Beispiel #16
0
		public void ParseSwitchWithExcessArguments()
		{
			const string Name1 = "name1";
			const string Name2 = "name2";
			const string Value1 = "value1";
			const string Value2 = "value2";
			const string Value3 = "value3";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name1),
				Value1,
				Value2,
				Switch.GetPrefixedName(Name2)
			};

			string[] argumentNames = new string[] { "arg1", "arg2" };

			string[] enoughValues = new string[] { Value1, Value2 };

			string[] excessValues = new string[] { Value1, Value2, Value3 };

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1, NoLongName, NoDescription, IsRequired, argumentNames);
			switches.Add(Name2);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsFalse(parser.IsParsed(Name1));
			Assert.IsFalse(parser.IsParsed(Name2));

			// No exceptions should be thrown. Excess arguments should be ignored.
			Assert.DoesNotThrow(delegate { parser.Parse(); });

			Assert.AreEqual(enoughValues, parser.GetValues(Name1));

			Assert.AreNotEqual(excessValues, parser.GetValues(Name1));

			Assert.IsTrue(parser.IsParsed(Name1));
			Assert.IsTrue(parser.IsParsed(Name2));
		}
Beispiel #17
0
		public void ParseNoSwitches()
		{
			const string ArgumentName1 = "arg1";
			const string ArgumentName2 = "arg2";
			const string Name1 = "name1";
			const string Name2 = "name2";

			string[] arguments = new string[]
			{
				ArgumentName1,
				ArgumentName2
			};

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1);
			switches.Add(Name2);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsFalse(parser.IsParsed(ArgumentName1));
			Assert.IsFalse(parser.IsParsed(ArgumentName2));
			Assert.IsFalse(parser.IsParsed(Name1));
			Assert.IsFalse(parser.IsParsed(Name2));

			parser.Parse();

			Assert.IsFalse(parser.IsParsed(ArgumentName1));
			Assert.IsFalse(parser.IsParsed(ArgumentName2));
			Assert.IsFalse(parser.IsParsed(Name1));
			Assert.IsFalse(parser.IsParsed(Name2));
		}
Beispiel #18
0
		////////////////////////////////////////////////////////////////////////
		// Constructors

		/// <summary>
		/// Constructor for specifying executable name and switches to be
		/// printed.
		/// </summary>
		/// <param name="executableName">
		/// String representing executable name.
		/// </param>
		/// <param name="switches">
		/// SwitchCollection representing collection of switches to be printed.
		/// </param>
		public HelpPrinter(string executableName, SwitchCollection switches)
		{
			if (string.IsNullOrEmpty(executableName) || switches == null)
				throw new ArgumentNullException();

			m_executableName = executableName;

			m_switches = new List<Switch>();
			m_switches.AddRange(switches.SortedSwitches);
		}
Beispiel #19
0
 static void Main(string[] args)
 {
     SwitchCollection switch_coll = new SwitchCollection(NetworkEventsFactory.GetNetworkEvents());
 }
Beispiel #20
0
		/// <summary>
		/// Constructor for specifying footer to be printed.
		/// </summary>
		/// <param name="executableName">
		/// String representing executable name.
		/// </param>
		/// <param name="switches">
		/// SwitchCollection representing collection of switches to be printed.
		/// </param>
		/// <param name="header">
		/// String representing header to be printed.
		/// </param>
		/// <param name="footer">
		/// String representing footer to be printed.
		/// </param>
		public HelpPrinter(string executableName, SwitchCollection switches,
			string header, string footer)
			: this(executableName, switches, header)
		{
			m_footer = footer;
		}
Beispiel #21
0
		public void ParseSwitchWithArguments()
		{
			const string Name1 = "name1";
			const string Name2 = "name2";
			const string Value1 = "value1";
			const string Value2 = "value2";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name1),
				Value1,
				Value2,
				Switch.GetPrefixedName(Name2)
			};

			string[] argumentNames = new string[] { "arg1", "arg2" };

			string[] values = new string[] { Value1, Value2 };

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1, NoLongName, NoDescription, IsRequired, argumentNames);
			switches.Add(Name2);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsFalse(parser.IsParsed(Name1));
			Assert.IsFalse(parser.IsParsed(Name2));

			parser.Parse();

			Assert.AreEqual(values, parser.GetValues(Name1));

			Assert.IsTrue(parser.IsParsed(Name1));
			Assert.IsTrue(parser.IsParsed(Name2));
		}
Beispiel #22
0
		public void NumberSwitchesParsedProperty()
		{
			const string Name1 = "arg1";
			const string Name2 = "arg2";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name1),
				Switch.GetPrefixedName(Name2)
			};

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1);
			switches.Add(Name2);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.AreEqual(NoSwitches, parser.NumberSwitchesParsed);
			Assert.AreEqual(NoSwitches, m_emptyParser.NumberSwitchesParsed);

			parser.Parse();

			Assert.AreEqual(switches.Count, parser.NumberSwitchesParsed);

			Assert.IsTrue(parser.IsParsed(Name1));
			Assert.IsTrue(parser.IsParsed(Name2));
		}
Beispiel #23
0
		public void ParseSwitchWithMissingArguments()
		{
			const string Name1 = "arg1";
			const string Name2 = "arg2";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name1),
				Switch.GetPrefixedName(Name2)
			};

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1);
			switches.Add(Name2, NoLongName, NoDescription, HasArguments, !IsRequired);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsFalse(parser.IsParsed(Name1));
			Assert.IsFalse(parser.IsParsed(Name2));

			Assert.Throws<ParsingException>(delegate { parser.Parse(); });

			Assert.IsTrue(parser.IsParsed(Name1));
			Assert.IsTrue(parser.IsParsed(Name2));
		}
Beispiel #24
0
		public void PrintNoLongNames()
		{
			const string Description1 = "First switch.";
			const string Description2 = "Second switch. This switch is required.";
			const string Name1 = "s1";
			const string Name2 = "s2";

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1, NoLongName, Description1);
			switches.Add(Name2, NoLongName, Description2, IsRequired);

			HelpPrinter helpPrinter = new HelpPrinter(ExecutableName, switches);

			helpPrinter.Print();

			StringBuilder expectedOutput = new StringBuilder();

			expectedOutput.AppendLine("Usage: " + ExecutableName + " [-s1] -s2");
			expectedOutput.AppendLine();
			expectedOutput.AppendLine("-s1   " + Description1);
			expectedOutput.AppendLine("-s2   " + Description2);

			Assert.AreEqual(expectedOutput.ToString(), Output);
		}
Beispiel #25
0
		public void ParseUndefinedSwitch()
		{
			const string Name1 = "arg1";
			const string Name2 = "arg2";
			const string UndefinedName = "arg3";

			string[] arguments = new string[]
			{
				Switch.GetPrefixedName(Name1),
				Switch.GetPrefixedName(UndefinedName),
				Switch.GetPrefixedName(Name2)
			};

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1);
			switches.Add(Name2);

			ArgumentParser parser = new ArgumentParser(arguments, switches);

			Assert.IsFalse(parser.IsParsed(Name1));
			Assert.IsFalse(parser.IsParsed(Name2));
			Assert.IsFalse(parser.IsParsed(UndefinedName));

			Assert.Throws<ParsingException>(delegate { parser.Parse(); });

			Assert.IsFalse(parser.IsParsed(Name2));
			Assert.IsFalse(parser.IsParsed(UndefinedName));

			Assert.IsTrue(parser.IsParsed(Name1));
		}
Beispiel #26
0
		public void PrintNonPrintable()
		{
			const string Name1 = "s1";
			const string Name2 = "s2";

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1);
			switches.Add(Name2, IsRequired);

			HelpPrinter helpPrinter = new HelpPrinter(ExecutableName, switches);

			helpPrinter.Print();

			StringBuilder expectedOutput = new StringBuilder();

			expectedOutput.AppendLine("Usage: " + ExecutableName + " [-s1] -s2");

			Assert.AreEqual(expectedOutput.ToString(), Output);
		}
Beispiel #27
0
        /// <summary>
        /// Define expected switches to parse from command-line arguments.
        /// </summary>
        static void DefineSwitches()
        {
            s_switches = new SwitchCollection();

            s_switches.Add(SwitchNames.Help,
                Resources.HelpSwitchLongName,
                Resources.HelpSwitchDescription);

            s_switches.Add(SwitchNames.ConfigurationFlags,
                Resources.ConfigurationFlagsSwitchLongName,
                Resources.ConfigurationFlagsSwitchDescription,
                true,
                false,
                Resources.ConfigurationFlagsSwitchArgumentName);

            s_switches.Add(SwitchNames.OutputFile,
                Resources.OutputFileSwitchLongName,
                Resources.OutputFileSwitchDescription,
                false,
                Resources.OutputFileSwitchArgumentName);

            s_switches.Add(SwitchNames.ProjectFiles,
                Resources.ProjectFilesSwitchLongName,
                Resources.ProjectFilesSwitchDescription,
                true,
                false,
                Resources.ProjectFilesSwitchArgumentName);

            s_switches.Add(SwitchNames.RecursiveSearch,
                Resources.RecursiveSearchSwitchLongName,
                Resources.RecursiveSearchSwitchDescription);

            s_switches.Add(SwitchNames.SettingsFile,
                Resources.SettingsFileSwitchLongName,
                Resources.SettingsFileSwitchDescription,
                false,
                Resources.SettingsFileSwitchArgumentName);

            s_switches.Add(SwitchNames.SolutionFiles,
                Resources.SolutionFilesSwitchLongName,
                Resources.SolutionFilesSwitchDescription,
                true,
                false,
                Resources.SolutionFilesSwitchArgumentName);

            s_switches.Add(SwitchNames.SourceFiles,
                Resources.SourceFilesSwitchLongName,
                Resources.SourceFilesSwitchDescription,
                true,
                false,
                Resources.SourceFilesSwitchArgumentName);
        }
Beispiel #28
0
		public void Print()
		{
			const string ArgumentName = "arg";
			const string Description1 = "First switch.";
			const string Description2 = "Second switch. This switch is required.";
			const string Description3 = "Third switch. This switch is required and has an argument.";
			const string LongName1 = "switch1";
			const string LongName2 = "switch2";
			const string LongName3 = "switch3";
			const string Name1 = "s1";
			const string Name2 = "s2";
			const string Name3 = "s3";

			SwitchCollection switches = new SwitchCollection();

			switches.Add(Name1, LongName1, Description1);
			switches.Add(Name2, LongName2, Description2, IsRequired);
			switches.Add(Name3, LongName3, Description3, HasArguments, IsRequired, ArgumentName);

			HelpPrinter helpPrinter = new HelpPrinter(ExecutableName, switches, GetHeader(), GetFooter());

			helpPrinter.Print();

			StringBuilder expectedOutput = new StringBuilder();

			expectedOutput.AppendLine(GetHeader());
			expectedOutput.AppendLine();
			expectedOutput.AppendLine("Usage: " + ExecutableName + " [-s1] -s2 -s3 <arg>");
			expectedOutput.AppendLine();
			expectedOutput.AppendLine("-s1, --switch1         " + Description1);
			expectedOutput.AppendLine("-s2, --switch2         " + Description2);
			expectedOutput.AppendLine("-s3, --switch3 <arg>   Third switch. This switch is required and has an ");
			expectedOutput.AppendLine("                       argument.");
			expectedOutput.AppendLine();
			expectedOutput.AppendLine(GetFooter());

			Assert.AreEqual(expectedOutput.ToString(), Output);
		}