|
1 |
| -using System; |
2 | 1 | using MySql.Data.MySqlClient;
|
3 | 2 | using Xunit;
|
4 | 3 |
|
5 | 4 | namespace SideBySide
|
6 | 5 | {
|
7 |
| - public class RequiresFeatureFactAttribute : FactAttribute |
| 6 | + public class SkippableFactAttribute : FactAttribute |
8 | 7 | {
|
9 |
| - public RequiresFeatureFactAttribute() |
| 8 | + public SkippableFactAttribute() |
| 9 | + : this(ServerFeatures.None, ConfigSettings.None) |
10 | 10 | {
|
11 | 11 | }
|
12 | 12 |
|
13 |
| - public RequiresFeatureFactAttribute(ServerFeatures features) |
| 13 | + public SkippableFactAttribute(ServerFeatures serverFeatures) |
| 14 | + : this(serverFeatures, ConfigSettings.None) |
14 | 15 | {
|
15 |
| - if (!AppConfig.SupportedFeatures.HasFlag(features)) |
16 |
| - Skip = "Doesn't support " + features; |
17 | 16 | }
|
18 | 17 |
|
19 |
| - public bool RequiresSsl |
20 |
| - { |
21 |
| - get => m_requiresSsl; |
22 |
| - set |
23 |
| - { |
24 |
| - m_requiresSsl = value; |
25 |
| - if (m_requiresSsl) |
26 |
| - { |
27 |
| - var csb = AppConfig.CreateConnectionStringBuilder(); |
28 |
| - if (csb.SslMode == MySqlSslMode.None || csb.SslMode == MySqlSslMode.Preferred) |
29 |
| - Skip = "SSL not explicitly required"; |
30 |
| - } |
31 |
| - } |
32 |
| - } |
33 |
| - |
34 |
| - private bool m_requiresSsl; |
35 |
| - } |
36 |
| - |
37 |
| - public class RequiresFeatureTheoryAttribute : TheoryAttribute |
38 |
| - { |
39 |
| - public RequiresFeatureTheoryAttribute() |
| 18 | + public SkippableFactAttribute(ConfigSettings configSettings) |
| 19 | + : this(ServerFeatures.None, configSettings) |
40 | 20 | {
|
41 | 21 | }
|
42 | 22 |
|
43 |
| - public RequiresFeatureTheoryAttribute(ServerFeatures features) |
| 23 | + public SkippableFactAttribute(ServerFeatures serverFeatures, ConfigSettings configSettings) |
44 | 24 | {
|
45 |
| - if (!AppConfig.SupportedFeatures.HasFlag(features)) |
46 |
| - Skip = "Doesn't support " + features; |
| 25 | + Skip = TestUtilities.GetSkipReason(serverFeatures, configSettings); |
47 | 26 | }
|
48 | 27 |
|
49 |
| - public bool RequiresSsl |
| 28 | + public string Baseline |
50 | 29 | {
|
51 |
| - get => m_requiresSsl; |
| 30 | + get => null; |
52 | 31 | set
|
53 | 32 | {
|
54 |
| - m_requiresSsl = value; |
55 |
| - if (m_requiresSsl) |
56 |
| - { |
57 |
| - var csb = AppConfig.CreateConnectionStringBuilder(); |
58 |
| - if (csb.SslMode == MySqlSslMode.None || csb.SslMode == MySqlSslMode.Preferred) |
59 |
| - Skip = "SSL not explicitly required"; |
60 |
| - } |
| 33 | +#if BASELINE |
| 34 | + Skip = value; |
| 35 | +#endif |
61 | 36 | }
|
62 | 37 | }
|
63 |
| - |
64 |
| - private bool m_requiresSsl; |
65 | 38 | }
|
66 | 39 |
|
67 |
| - public class PasswordlessUserFactAttribute : FactAttribute |
| 40 | + public class SkippableTheoryAttribute : TheoryAttribute |
68 | 41 | {
|
69 |
| - public PasswordlessUserFactAttribute() |
| 42 | + public SkippableTheoryAttribute() |
| 43 | + : this(ServerFeatures.None, ConfigSettings.None) |
70 | 44 | {
|
71 |
| - if(string.IsNullOrWhiteSpace(AppConfig.PasswordlessUser)) |
72 |
| - Skip = "No passwordless user"; |
73 | 45 | }
|
74 |
| - } |
75 | 46 |
|
76 |
| - public class BulkLoaderCsvFileFactAttribute : FactAttribute |
77 |
| - { |
78 |
| - public BulkLoaderCsvFileFactAttribute() |
| 47 | + public SkippableTheoryAttribute(ServerFeatures serverFeatures) |
| 48 | + : this(serverFeatures, ConfigSettings.None) |
79 | 49 | {
|
80 |
| - if(string.IsNullOrWhiteSpace(AppConfig.MySqlBulkLoaderCsvFile)) |
81 |
| - Skip = "No bulk loader CSV file specified"; |
82 | 50 | }
|
83 |
| - } |
84 | 51 |
|
85 |
| - public class BulkLoaderTsvFileFactAttribute : FactAttribute |
86 |
| - { |
87 |
| - public BulkLoaderTsvFileFactAttribute() |
| 52 | + public SkippableTheoryAttribute(ConfigSettings configSettings) |
| 53 | + : this(ServerFeatures.None, configSettings) |
88 | 54 | {
|
89 |
| - if(string.IsNullOrWhiteSpace(AppConfig.MySqlBulkLoaderTsvFile)) |
90 |
| - Skip = "No bulk loader TSV file specified"; |
91 | 55 | }
|
92 |
| - } |
93 | 56 |
|
94 |
| - public class BulkLoaderLocalCsvFileFactAttribute : FactAttribute |
95 |
| - { |
96 |
| - public BulkLoaderLocalCsvFileFactAttribute() |
| 57 | + public SkippableTheoryAttribute(ServerFeatures serverFeatures, ConfigSettings configSettings) |
97 | 58 | {
|
98 |
| - if(string.IsNullOrWhiteSpace(AppConfig.MySqlBulkLoaderLocalCsvFile)) |
99 |
| - Skip = "No bulk loader local CSV file specified"; |
| 59 | + Skip = TestUtilities.GetSkipReason(serverFeatures, configSettings); |
100 | 60 | }
|
101 | 61 |
|
102 |
| - public bool TrustedHost |
| 62 | + public string Baseline |
103 | 63 | {
|
104 |
| - |
105 |
| - get => _trustedHost; |
| 64 | + get => null; |
106 | 65 | set
|
107 | 66 | {
|
108 |
| - _trustedHost = value; |
109 |
| - |
110 |
| - var csb = AppConfig.CreateConnectionStringBuilder(); |
111 |
| - if (_trustedHost) |
112 |
| - { |
113 |
| - if (csb.SslMode == MySqlSslMode.None |
114 |
| - || csb.SslMode == MySqlSslMode.Preferred |
115 |
| - || csb.SslMode == MySqlSslMode.Required) |
116 |
| - Skip = "SslMode should be VerifyCA or higher."; |
117 |
| - } |
118 |
| - else |
119 |
| - { |
120 |
| - if (csb.SslMode == MySqlSslMode.VerifyCA |
121 |
| - || csb.SslMode == MySqlSslMode.VerifyFull) |
122 |
| - Skip = "SslMode should be less than VerifyCA."; |
123 |
| - } |
124 |
| - } |
125 |
| - } |
126 |
| - private bool _trustedHost; |
127 |
| - } |
128 |
| - |
129 |
| - public class BulkLoaderLocalTsvFileFactAttribute : FactAttribute |
130 |
| - { |
131 |
| - public BulkLoaderLocalTsvFileFactAttribute() |
132 |
| - { |
133 |
| - if(string.IsNullOrWhiteSpace(AppConfig.MySqlBulkLoaderLocalTsvFile)) |
134 |
| - Skip = "No bulk loader local TSV file specified"; |
135 |
| - } |
136 |
| - } |
137 |
| - |
138 |
| - public class UnbufferedResultSetsFactAttribute : FactAttribute |
139 |
| - { |
140 |
| -#if !BASELINE |
141 |
| - public UnbufferedResultSetsFactAttribute() |
142 |
| - { |
143 |
| - var csb = AppConfig.CreateConnectionStringBuilder(); |
144 |
| - if(csb.BufferResultSets == true) |
145 |
| - Skip = "Do not run when BufferResultSets are used"; |
146 |
| - } |
| 67 | +#if BASELINE |
| 68 | + Skip = value; |
147 | 69 | #endif
|
148 |
| - } |
149 |
| - |
150 |
| - public class TcpConnectionFactAttribute : FactAttribute |
151 |
| - { |
152 |
| - public TcpConnectionFactAttribute() |
153 |
| - { |
154 |
| - var csb = AppConfig.CreateConnectionStringBuilder(); |
155 |
| - if(csb.Server.StartsWith("/", StringComparison.Ordinal) || csb.Server.StartsWith("./", StringComparison.Ordinal)) |
156 |
| - Skip = "Not a TCP Connection"; |
157 |
| - } |
158 |
| - } |
159 |
| - |
160 |
| - public class SecondaryDatabaseRequiredFactAttribute : FactAttribute |
161 |
| - { |
162 |
| - public SecondaryDatabaseRequiredFactAttribute() |
163 |
| - { |
164 |
| - if (string.IsNullOrEmpty(AppConfig.SecondaryDatabase)) |
165 |
| - Skip = "No SecondaryDatabase specified."; |
| 70 | + } |
166 | 71 | }
|
167 | 72 | }
|
168 | 73 | }
|
0 commit comments