コード例 #1
0
        public void ValidateGetEnumerator()
        {
            AggregateNumbers aggregateNos = new AggregateNumbers();
            CommandLineArguments parser = new CommandLineArguments();

            //add parameters
            parser.Parameter(ArgumentType.Required, "InputFile", ArgumentValueType.String, "i", "File containing numbers to add");
            parser.Parameter(ArgumentType.Required, "ResultFile", ArgumentValueType.String, "r", "File to store output");
            string inputfileName = Path.GetTempFileName().Replace(Path.GetTempPath(), "");
            string outputfileName = Path.GetTempFileName().Replace(Path.GetTempPath(), "");
            string[] args = { "-InputFile:" + inputfileName, "-ResultFile:" + outputfileName };
            parser.Parse(args, aggregateNos);
            IEnumerator parsedVals =  parser.GetEnumerator();
            Assert.IsNotNull(parsedVals);
            string current = string.Empty;
            int count = 0;
            parser.Reset();
            while (parser.MoveNext())
            {
                current = parser.Current.ToString();
                ApplicationLog.WriteLine(current);
                count++;
            }
            Assert.AreEqual(2, count);
        }