|
| 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 | +} |
0 commit comments