Esempio n. 1
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));
		}
Esempio n. 2
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));
		}