Skip to content

Commit 4219d90

Browse files
committed
Refractor to allow for testing
1 parent 97f37d8 commit 4219d90

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

SSLLWrapper/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("1.0.1")]
3636
[assembly: AssemblyFileVersion("1.0.1")]
37+
[assembly: InternalsVisibleTo("SSLLWrapper.Tests")]

SSLLWrapper/SSLLService.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class SSLLService
1111
{
1212
#region construction
1313

14-
private readonly IApiProvider _api;
14+
private readonly IApiProvider _apiProvider;
1515
private readonly RequestModelFactory _requestModelFactory;
1616
private readonly ResponsePopulation _responsePopulation;
1717
private readonly UrlValidation _urlValidation;
@@ -43,15 +43,18 @@ public enum All
4343
Done
4444
}
4545

46-
public SSLLService(string apiUrl)
47-
{
48-
_api = new SSLLabsApi();
46+
public SSLLService(string apiUrl) : this(apiUrl, new SSLLabsApi())
47+
{
48+
}
49+
50+
internal SSLLService(string apiUrl, IApiProvider apiProvider)
51+
{
52+
_apiProvider = apiProvider;
4953
_requestModelFactory = new RequestModelFactory();
5054
_urlValidation = new UrlValidation();
5155
_responsePopulation = new ResponsePopulation();
52-
5356
ApiUrl = apiUrl;
54-
}
57+
}
5558

5659
#endregion
5760

@@ -65,7 +68,7 @@ public Info Info()
6568
try
6669
{
6770
// Making Api request and gathering response
68-
var webResponse = _api.MakeGetRequest(requestModel);
71+
var webResponse = _apiProvider.MakeGetRequest(requestModel);
6972

7073
// Binding result to model
7174
infoModel = _responsePopulation.InfoModel(webResponse, infoModel);
@@ -112,7 +115,7 @@ public Analyze Analyze(string host, Publish publish, ClearCache clearCache, From
112115
try
113116
{
114117
// Making Api request and gathering response
115-
var webResponse = _api.MakeGetRequest(requestModel);
118+
var webResponse = _apiProvider.MakeGetRequest(requestModel);
116119

117120
// Binding result to model
118121
analyzeModel = _responsePopulation.AnalyzeModel(webResponse, analyzeModel);
@@ -153,7 +156,7 @@ public Endpoint GetEndpointData(string host, string s, FromCache fromCache)
153156
try
154157
{
155158
// Making Api request and gathering response
156-
var webResponse = _api.MakeGetRequest(requestModel);
159+
var webResponse = _apiProvider.MakeGetRequest(requestModel);
157160

158161
// Binding result to model
159162
endpointModel = _responsePopulation.EndpointModel(webResponse, endpointModel);
@@ -180,7 +183,7 @@ public StatusDetails GetStatusCodes()
180183
try
181184
{
182185
// Making Api request and gathering response
183-
var webResponse = _api.MakeGetRequest(requestModel);
186+
var webResponse = _apiProvider.MakeGetRequest(requestModel);
184187

185188
// Binding result to model
186189
statusDetailsModel = _responsePopulation.StatusDetailsModel(webResponse, statusDetailsModel);

0 commit comments

Comments
 (0)