-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRunQueryTests.cs
87 lines (73 loc) · 2.84 KB
/
RunQueryTests.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Slicer.Test
{
public class RunQueryTests
{
public static void Main(string[] args)
{
bool _canceled = false;
// The query types to test
List<string> queryTypes = new List<string>(){
"count_entity",
"count_event",
"top_values",
"aggregation",
"result",
"score",
"sql",
"delete",
"update"
};
string apiKey = Environment.GetEnvironmentVariable("SD_API_KEY");
if (String.IsNullOrEmpty(apiKey)) {
apiKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiIxNTI0MjQ4ODIwMDEyIiwicGVybWlzc2lvbl9sZXZlbCI6MywicHJvamVjdF9pZCI6MzAwMzAsImNsaWVudF9pZCI6MTF9.PpdlQxFmLSFFtKDeu1ECtA-YWYycyW5Bkk_UDcqetN4";
}
// Testing class with demo API key
// To get a new Demo API key visit: http://panel.slicingdice.com/docs/#api-details-api-connection-api-keys-demo-key
SlicingDiceTester sdTester = new SlicingDiceTester(apiKey, verbose: false);
Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
{
e.Cancel = true;
showResults(sdTester);
};
foreach(string queryType in queryTypes){
sdTester.RunTests(queryType);
}
showResults(sdTester);
}
// Show test results
private static void showResults(SlicingDiceTester sdTester)
{
System.Console.WriteLine("\n");
System.Console.WriteLine("Results:");
System.Console.WriteLine(string.Format(" Successes: {0}", sdTester.NumSuccesses));
System.Console.WriteLine(string.Format(" Fails: {0}", sdTester.NumFails));
foreach (dynamic failedTest in sdTester.FailedTests)
{
System.Console.WriteLine(" - {0}", (string)failedTest);
}
System.Console.WriteLine();
if (sdTester.NumFails > 0)
{
bool isSingular = sdTester.NumFails == 1;
string testOrTests = string.Empty;
if (isSingular)
{
testOrTests = "test has";
}
else
{
testOrTests = "test have";
}
System.Console.WriteLine(string.Format("FAIL: {0} {1} failed", sdTester.NumFails, testOrTests));
System.Environment.Exit(1);
}
System.Console.WriteLine("SUCCESS: All tests passed");
System.Environment.Exit(Environment.ExitCode);
}
}
}