-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_MyTestValuesLoader.cs
68 lines (57 loc) · 1.96 KB
/
_MyTestValuesLoader.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json.Linq;
// https://csharpindepth.com/articles/Singleton
namespace MySQLCLRFunctions.Tests
{
public class TestSet
{
public string TestArea;
public string TestName;
public string input;
public string expected;
public bool TruePositiveFalseNegative;
}
public sealed class _MyTestValuesLoader
{
private static readonly Lazy<_MyTestValuesLoader>
lazy =
new Lazy<_MyTestValuesLoader>
(() => new _MyTestValuesLoader());
public static _MyTestValuesLoader Instance { get { return lazy.Value; } }
dynamic testSets;
private _MyTestValuesLoader()
{
var inputFile = new FileInfo(@"C:\Users\humphrej2\source\repos\jeffshumphreys\MySQLCLRFunctions\MySQLCLRFunctionsTests\_MyTestValues.json");
if (!inputFile.Exists)
{
inputFile = new FileInfo(@"C:\Users\humphrej2\source\repos\jeffshumphreys\MySQLCLRFunctions\MySQLCLRFunctionsTests\_GenericTestValues.json");
}
;
testSets = JArray.Parse(File.ReadAllText(inputFile.FullName));
}
/* Payload */
public TestSet[] PingableValidAddresses
{
get
{
IList<TestSet> testsets = testSets[0].Ping.ValidAddresses.ToObject<IList<TestSet>>();
TestSet[] testsetsAsArray = testsets.ToArray<TestSet>();
return testsetsAsArray;
}
}
public TestSet[] UnpingableAddresses
{
get
{
IList<TestSet> testsets = testSets[0].Ping.BadAddresses.ToObject<IList<TestSet>>();
TestSet[] testsetsAsArray = testsets.ToArray<TestSet>();
return testsetsAsArray;
}
}
}
}