public void Test_SingleInfo() { ArgsParser parser = new ArgsParser("1公里,等待0分钟"); var args = parser.GetArgs(); Assert.AreEqual(args[0].Mileage, 1); Assert.AreEqual(args[0].Waiting, 0); }
public void Test_InvalidParam_InvalidSeperator() { ArgsParser parser = new ArgsParser("1公里,等待0分钟\n2公里,等待5分钟"); var args = parser.GetArgs(); Assert.AreEqual(args[0].Mileage, 1); Assert.AreEqual(args[0].Waiting, 0); Assert.AreEqual(args.Count, 1); }
public void Test_TwoInfo() { ArgsParser parser = new ArgsParser("1公里,等待0分钟\n2公里,等待5分钟"); var args = parser.GetArgs(); Assert.AreEqual(args[0].Mileage, 1); Assert.AreEqual(args[0].Waiting, 0); Assert.AreEqual(args[1].Mileage, 2); Assert.AreEqual(args[1].Waiting, 5); }
static void Main(string[] args) { string textData = GetTestData(args); if (string.IsNullOrEmpty(textData)) { Console.WriteLine("Get Test Data Failed"); } else { var parser = new ArgsParser(textData); var texiArgs = parser.GetArgs(); var priceCal = new TexiPriceCalculor(); texiArgs.ForEach(arg => Console.WriteLine(string.Format(pricePrintFormat, priceCal.GetPrice(arg)))); } Console.ReadKey(); }