示例#1
0
 public void EnumHelp()
 {
     using (var c = new CaptureConsoleOutput())
     {
         var a = new ValueParserTestApplication();
         Assert.AreEqual(0, Sidi.GetOpt.GetOpt.Run(a, new[] { "--help" }));
         foreach (var n in Enum.GetNames(typeof(ValueParserTestApplication.Fruits)))
         {
             StringAssert.Contains(n, c.output.ToString());
         }
     }
 }
示例#2
0
        public void ParseValues()
        {
            using (var c = new CaptureConsoleOutput())
            {
                var a = new ValueParserTestApplication();
                Assert.AreEqual(0, Sidi.GetOpt.GetOpt.Run(a, new[] { "--birthday=2394-03-01" }));
                Assert.AreEqual(new DateTime(2394, 3, 1, 0, 0, 0), a.Birthday);

                Assert.AreEqual(0, Sidi.GetOpt.GetOpt.Run(a, new[] { "--duration=1.2:3:4.5" }));
                Assert.AreEqual(new TimeSpan(1, 2, 3, 4, 500), a.Duration);

                Assert.AreEqual(0, Sidi.GetOpt.GetOpt.Run(a, new[] { "--duration=0:10" }));
                Assert.AreEqual(TimeSpan.FromMinutes(10), a.Duration);

                Assert.AreEqual(0, Sidi.GetOpt.GetOpt.Run(a, new[] { "--fruit=orange" }));
                Assert.AreEqual(ValueParserTestApplication.Fruits.Orange, a.Fruit);

                Assert.AreEqual(0, Sidi.GetOpt.GetOpt.Run(a, new[] { "--fruit=o" }));
                Assert.AreEqual(ValueParserTestApplication.Fruits.Orange, a.Fruit);
            }
        }