public void Arguments_should_be_removable() { var args = new CmdArgumentsService(); args.Set("Argument1", "Value1"); args.Remove("Argument1"); Assert.IsEmpty(args.AllKeys); }
public void If_requested_it_correctly_determin_if_a_argument_was_given() { var args = new CmdArgumentsService(); args.Set("Argument1", "Value1"); Assert.IsTrue(args.IsSet("Argument1")); Assert.IsFalse(args.IsSet("Argument2")); }
public void Arguments_should_be_correctly_assembled_to_a_string() { var args = new CmdArgumentsService(); args.Set("Arg1","1"); args.Set("Arg2", null); args.Set("Arg3", "\"2\""); Assert.AreEqual("Arg1=1 Arg2 Arg3=\"\"\"2\"\"\"", args.ToCommandLineString()); }
public void If_requested_it_should_return_the_correct_param_values_as_the_requested_type() { var args = new CmdArgumentsService(); args.Set("Argument1", "1"); args.Set("Argument2", 2.2.ToString(CultureInfo.CurrentCulture)); Assert.AreEqual(1, args.Get<int>("Argument1")); Assert.AreEqual(2.2, args.Get<double>("Argument2")); Assert.AreEqual(0, args.Get<int>("Argument3")); }
public void If_requested_it_should_return_the_correct_param_values_as_strings() { var args = new CmdArgumentsService(); args.Set("Argument1", "Value1"); args.Set("Argument2", "Value2"); Assert.AreEqual("Value1", args.Get("Argument1")); Assert.AreEqual("Value2", args.Get("Argument2")); Assert.IsNull(args.Get("Param3")); }
public void State_should_be_correctly_stored_and_restored() { var args = new CmdArgumentsService(); args.Set("Argument1", "Value1"); args.SaveState(); Assert.AreEqual(1, args.AllKeys.Length); args.RemoveAll(); Assert.AreEqual(0, args.AllKeys.Length); args.RestoreState(); Assert.AreEqual(1, args.AllKeys.Length); }
public void A_assembled_argument_string_should_be_parsed_the_the_same_result() { var args = new CmdArgumentsService(); args.Set("key1", "value1"); args.Set("key2", null); args.Set("key3", "value\"with\"quote"); var result = PrepareInstance<ICmdArguments>(new CmdArgumentsService()); PrepareInstance<ICmdParser>(new CmdParser()); CreateInstance<CommandLine>().ParseArguments(args.ToCommandLineString()); Assert.AreEqual(3, result.AllKeys.Length); Assert.AreEqual("value1", result.Get("key1")); Assert.AreEqual(null, result.Get("key2")); Assert.AreEqual("value\"with\"quote", result.Get("key3")); }