forked from alexeisnyk/juliet-test-suite-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs.template
124 lines (95 loc) · 3.36 KB
/
Program.cs.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
namespace $TestCaseNamespace$
{
class Program {
static void Main(string[] args) {
if(args.Any()) {
if(args[0].Equals("-h", StringComparison.OrdinalIgnoreCase) ||
args[0].Equals("--help", StringComparison.OrdinalIgnoreCase)) {
Console.WriteLine("To use this main, you can either run the program with no " +
"command line arguments to run all test cases or you can specify one or more classes to test");
System.Environment.Exit(1);
}
/* User supplied some class names on the command line, just use those with introspection
*
* string classNames[] = { "CWE481_Assigning_instead_of_Comparing__boolean_01",
* "CWE476_Null_Pointer_Dereference__getProperty_01" };
* could read class names from command line or use
* http://sadun-util.sourceforge.net/api/org/sadun/util/
* ClassPackageExplorer.html
*/
foreach (string className in args) {
try {
/* String classNameWithPackage = "testcases." + className; */
/* Console.WriteLine("classNameWithPackage = " + classNameWithPackage); */
Type myClass = Type.GetType(className);
object myObject = Activator.CreateInstance(myClass);
myClass.InvokeMember("runTest",
BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public,
null,
myObject,
new object[] { className });
} catch (Exception ex) {
Console.WriteLine("Could not run test for class " + className);
Console.WriteLine(ex.StackTrace);
}
Console.WriteLine(""); /* leave a blank line between classes */
}
} else {
/* No command line args were used, we want to run every testcase */
/* needed to separate these calls into other methods because
we were running into the size limit Java has for a single method */
RunTestCWE1();
RunTestCWE2();
RunTestCWE3();
RunTestCWE4();
RunTestCWE5();
RunTestCWE6();
RunTestCWE7();
RunTestCWE8();
RunTestCWE9();
}
}
private static void RunTestCWE1() {
/* BEGIN-AUTOGENERATED-CSHARP-TESTS-1 */
/* END-AUTOGENERATED-CSHARP-TESTS-1 */
}
private static void RunTestCWE2() {
/* BEGIN-AUTOGENERATED-CSHARP-TESTS-2 */
/* END-AUTOGENERATED-CSHARP-TESTS-2 */
}
private static void RunTestCWE3() {
/* BEGIN-AUTOGENERATED-CSHARP-TESTS-3 */
/* END-AUTOGENERATED-CSHARP-TESTS-3 */
}
private static void RunTestCWE4() {
/* BEGIN-AUTOGENERATED-CSHARP-TESTS-4 */
/* END-AUTOGENERATED-CSHARP-TESTS-4 */
}
private static void RunTestCWE5() {
/* BEGIN-AUTOGENERATED-CSHARP-TESTS-5 */
/* END-AUTOGENERATED-CSHARP-TESTS-5 */
}
private static void RunTestCWE6() {
/* BEGIN-AUTOGENERATED-CSHARP-TESTS-6 */
/* END-AUTOGENERATED-CSHARP-TESTS-6 */
}
private static void RunTestCWE7() {
/* BEGIN-AUTOGENERATED-CSHARP-TESTS-7 */
/* END-AUTOGENERATED-CSHARP-TESTS-7 */
}
private static void RunTestCWE8() {
/* BEGIN-AUTOGENERATED-CSHARP-TESTS-8 */
/* END-AUTOGENERATED-CSHARP-TESTS-8 */
}
private static void RunTestCWE9() {
/* BEGIN-AUTOGENERATED-CSHARP-TESTS-9 */
/* END-AUTOGENERATED-CSHARP-TESTS-9 */
}
}
}