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

Annotation of /trunk/gr2lib_UnitTest/Program.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 65 - (hide annotations) (download)
Thu Jul 15 08:37:02 2010 UTC (9 years, 6 months ago) by william
File size: 2113 byte(s)
add support for passing file on commandline

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

  ViewVC Help
Powered by ViewVC 1.1.22