/[gr2lib]/trunk/gr2lib_UnitTest/Program.cs
ViewVC logotype

Annotation of /trunk/gr2lib_UnitTest/Program.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69 - (hide annotations) (download)
Thu Jul 15 09:29:25 2010 UTC (9 years, 6 months ago) by william
File size: 2358 byte(s)
fix commandline parsing

1 william 9 using System;
2     using System.Collections.Generic;
3     using System.Text;
4    
5 william 16 using gr2lib.core;
6     using gr2lib.core.apiversion;
7 william 50 using gr2lib.core.exceptions;
8 william 69 using gr2lib.core.helpers;
9 william 16
10 william 9 namespace gr2lib_UnitTest
11     {
12 william 58
13 william 9 class Program
14     {
15     static void Main(string[] args)
16     {
17 william 65 string GrannyFilename = shared.GRANNY_TEST_FILE;
18 william 50 try
19     {
20     // Setup access to check loaded Granny2 API Version
21 william 58 granny2apiversion apiversion = new granny2apiversion(shared.EXPECTED_API_VERSION);
22 william 16
23 william 50 // Check if the Loaded API Version Matches
24     if (!apiversion.apiversionsmatch)
25     {
26     // the loaded version does not match
27     Console.WriteLine("Warning:\n" +
28     "\t Loaded Granny2 DLL Version: " + apiversion.apiversion.version + "\n" +
29     "\t Expected Version: " + apiversion.expectedapiversion.version);
30     // return from void to exit application
31     return;
32     }
33     else
34     {
35     // the loaded version matches
36     Console.WriteLine("Loaded granny2.dll: " + apiversion.apiversion.version);
37     }
38 william 65
39     // parse commandline
40 william 69 if (args.Length == 1)
41 william 65 {
42 william 69 GrannyFilename = args[0];
43 william 65 }
44 william 69 else if (args.Length > 1)
45     {
46     throw new InvalidOperationException("ERROR: Recieved Invalid Commandline: " + new arraytostring<string,string[]>(args));
47     }
48 william 61
49 william 65 if (System.IO.File.Exists(GrannyFilename))
50     {
51     Console.WriteLine("Using Granny2 File: " + GrannyFilename);
52     }
53     else
54     {
55     throw new System.IO.FileNotFoundException("Unable to find: " + GrannyFilename);
56     }
57 william 61
58 william 65
59 william 61
60    
61 william 16 }
62 william 50 catch (granny2apiloadexception ex)
63 william 16 {
64 william 69 Console.WriteLine(ex.Message);
65 william 16 }
66 william 58 catch (Exception ex)
67     {
68 william 69 Console.WriteLine(ex.Message);
69 william 58 }
70 william 9 }
71     }
72     }

  ViewVC Help
Powered by ViewVC 1.1.22