Skip to content

Commit 76b0fe5

Browse files
committed
Adding automatic analyze method tests
1 parent a99ff9e commit 76b0fe5

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System.Configuration;
2+
using FluentAssertions;
3+
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
using SSLLWrapper;
5+
using SSLLWrapper.Models.Response;
6+
7+
namespace given_that_I_make_a_automaticanalyze_request
8+
{
9+
[TestClass]
10+
public class when_i_expect_a_successful_result
11+
{
12+
private static SSLLService _ssllService;
13+
private static Analyze _analyze;
14+
private static string _host;
15+
16+
[ClassInitialize]
17+
public static void Setup(TestContext testContext)
18+
{
19+
_host = ConfigurationManager.AppSettings.Get("EndpointHost");
20+
_ssllService = new SSLLService(ConfigurationManager.AppSettings.Get("ApiUrl"));
21+
_analyze = _ssllService.AutomaticAnalyze(_host);
22+
}
23+
24+
[TestMethod]
25+
public void then_the_error_count_should_be_zero()
26+
{
27+
_analyze.Errors.Count.Should().Be(0);
28+
}
29+
30+
[TestMethod]
31+
public void then_HasErrorOccurred_should_be_false()
32+
{
33+
_analyze.HasErrorOccurred.Should().BeFalse();
34+
}
35+
36+
[TestMethod]
37+
public void then_status_code_header_should_be_greater_than_zero()
38+
{
39+
_analyze.Header.statusCode.Should().BeGreaterThan(0);
40+
}
41+
42+
[TestMethod]
43+
public void then_status_code_header_should_not_be_404()
44+
{
45+
_analyze.Header.statusCode.Should().NotBe(404);
46+
}
47+
48+
[TestMethod]
49+
public void then_should_not_trigger_an_api_invocation_error()
50+
{
51+
_analyze.Header.statusCode.Should().NotBe(400);
52+
}
53+
54+
[TestMethod]
55+
public void then_should_analyze_status_should_not_be_null()
56+
{
57+
_analyze.status.Should().NotBeNullOrEmpty();
58+
}
59+
60+
[TestMethod]
61+
public void then_start_time_should_be_greater_than_zero()
62+
{
63+
_analyze.startTime.Should().BeGreaterThan(0);
64+
}
65+
66+
[TestMethod]
67+
public void then_the_host_in_the_response_should_match_the_request()
68+
{
69+
_analyze.host.Should().Match(_host);
70+
}
71+
}
72+
}

SSLLWrapper.IntegrationTests/SSLLWrapper.IntegrationTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
</Otherwise>
6565
</Choose>
6666
<ItemGroup>
67+
<Compile Include="AutomaticAnalyzeTests.cs" />
6768
<Compile Include="AnalyzeTests.cs" />
6869
<Compile Include="GetEndpointDetails.cs" />
6970
<Compile Include="GetStatusCodesTests.cs" />

SSLLWrapper/SSLLService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public Analyze Analyze(string host, Publish publish, ClearCache clearCache, From
131131

132132
public Analyze AutomaticAnalyze(string host)
133133
{
134-
return AutomaticAnalyze(host, 300, 1000);
134+
return AutomaticAnalyze(host, 300, 15);
135135
}
136136

137137
public Analyze AutomaticAnalyze(string host, int maxWaitInterval, int sleepInterval)
@@ -142,7 +142,7 @@ public Analyze AutomaticAnalyze(string host, int maxWaitInterval, int sleepInter
142142
public Analyze AutomaticAnalyze(string host, Publish publish, ClearCache clearCache, FromCache fromCache, All all, int maxWaitInterval, int sleepInterval)
143143
{
144144
var startTime = DateTime.Now;
145-
var sleepIntervalMilliseconds = sleepInterval * 10;
145+
var sleepIntervalMilliseconds = sleepInterval * 1000;
146146
var analyzeModel = Analyze(host, publish, clearCache, fromCache, all);
147147

148148
// Shouldn't have to check status header as HasErrorOccurred should be enough

0 commit comments

Comments
 (0)