Skip to content

Commit

Permalink
Update tests, remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
basdijkstra committed Nov 20, 2024
1 parent ac4ddbe commit 0bf817e
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 17 deletions.
2 changes: 0 additions & 2 deletions RestAssured.Net.Tests/JsonRequestBodySerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
// </copyright>
namespace RestAssured.Tests
{
using System;
using System.Collections.Generic;
using NUnit.Framework;
using RestAssured.Request.Exceptions;
using RestAssured.Tests.Models;
using WireMock.Matchers;
using WireMock.RequestBuilders;
Expand Down
2 changes: 0 additions & 2 deletions RestAssured.Net.Tests/LoggingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace RestAssured.Tests
using NUnit.Framework;
using RestAssured.Logging;
using RestAssured.Request.Builders;
using RestAssured.Request.Logging;
using RestAssured.Response.Logging;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using static RestAssured.Dsl;
Expand Down
1 change: 0 additions & 1 deletion RestAssured.Net.Tests/NtlmAuthenticationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
namespace RestAssured.Tests
{
using NUnit.Framework;
using WireMock.Matchers;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using static RestAssured.Dsl;
Expand Down
5 changes: 2 additions & 3 deletions RestAssured.Net.Tests/QueryParameterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public class QueryParameterTests : TestBase
public void CreateRequestSpecifications()
{
this.requestSpecification = new RequestSpecBuilder()
.WithScheme("http")
.WithHostName("localhost")
.WithBaseUri("http://localhost")
.WithBasePath("api")
.WithPort(MOCK_SERVER_PORT)
.Build();
Expand Down Expand Up @@ -131,7 +130,7 @@ public void MultipleQueryParametersCanBeSpecifiedUsingADictionary()
[Test]
public void MultipleQueryParametersCanBeSpecifiedUsingAListOfKeyValuePairs()
{
List<KeyValuePair<string, object>> queryParams = new List<KeyValuePair<string, object>>()
var queryParams = new List<KeyValuePair<string, object>>()
{
new KeyValuePair<string, object>("name", this.name),
new KeyValuePair<string, object>("id", this.firstId),
Expand Down
1 change: 1 addition & 0 deletions RestAssured.Net.Tests/RequestBodyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class RequestBodyTests : TestBase
/// A test demonstrating RestAssuredNet syntax for sending
/// a plaintext request body when performing an HTTP POST.
/// </summary>
/// <param name="bodySize">The size of the plaintext request body.</param>
[TestCase("small", TestName = "Sending small plaintext request body")]
[TestCase("medium", TestName = "Sending medium plaintext request body")]
[TestCase("large", TestName = "Sending large plaintext request body")]
Expand Down
8 changes: 7 additions & 1 deletion RestAssured.Net.Tests/RequestSpecificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace RestAssured.Tests
{
using System.Text;
using NUnit.Framework;
using RestAssured.Logging;
using RestAssured.Request.Builders;
using RestAssured.Request.Exceptions;
using RestAssured.Request.Logging;
Expand All @@ -40,12 +41,17 @@ public class RequestSpecificationTests : TestBase
[TestCase("request-specification", TestName = "With base path in request specification, works without a leading /")]
public void FullRequestSpecificationCanBeUsed(string endpoint)
{
var logConfig = new LogConfiguration
{
RequestLogLevel = Logging.RequestLogLevel.All,
};

var fullRequestSpecification = new RequestSpecBuilder()
.WithBaseUri("http://localhost:9876")
.WithBasePath("api")
.WithQueryParam("param_name", "param_value")
.WithQueryParam("another_param_name", "another_param_value")
.WithRequestLogLevel(RequestLogLevel.All)
.WithLogConfiguration(logConfig)
.Build();

this.CreateStubForRequestSpecification();
Expand Down
1 change: 0 additions & 1 deletion RestAssured.Net.Tests/ResponseBodyHtmlVerificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// </copyright>
namespace RestAssured.Tests
{
using System.Net.Http;
using NUnit.Framework;
using RestAssured.Response;
using RestAssured.Response.Exceptions;
Expand Down
9 changes: 7 additions & 2 deletions RestAssured.Net.Tests/ResponseBodyLengthVerificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// </copyright>
namespace RestAssured.Tests
{
using System;
using System.Collections.Generic;
using NUnit.Framework;
using RestAssured.Logging;
using RestAssured.Response.Exceptions;
using RestAssured.Tests.Models;
using WireMock.RequestBuilders;
Expand Down Expand Up @@ -83,11 +83,16 @@ public void ResponseBodyLengthCanBeVerified()
{
this.CreateStubForJsonResponseBody();

var logConfig = new LogConfiguration
{
ResponseLogLevel = ResponseLogLevel.All,
};

Given()
.Log(logConfig)
.When()
.Get($"{MOCK_SERVER_BASE_URL}/json-response-body")
.Then()
.Log(RestAssured.Response.Logging.ResponseLogLevel.All)
.StatusCode(200)
.ResponseBodyLength(NHamcrest.Is.GreaterThan(25));
}
Expand Down
1 change: 1 addition & 0 deletions RestAssured.Net.Tests/ResponseBodyVerificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class ResponseBodyVerificationTests : TestBase
/// A test demonstrating RestAssuredNet syntax for verifying
/// a plaintext response body.
/// </summary>
/// <param name="bodySize">The plain text body size to be used in the test.</param>
[TestCase("small")]
[TestCase("medium")]
[TestCase("large")]
Expand Down
6 changes: 6 additions & 0 deletions RestAssured.Net.Tests/ResponseBodyXmlVerificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public class ResponseBodyXmlVerificationTests : TestBase
private int placeInhabitants;
private bool isCapital;

/// <summary>
/// Initializes test data used in these tests.
/// </summary>
[SetUp]
public void SetLocation()
{
Expand All @@ -62,6 +65,9 @@ public void SetLocation()
this.location.Places.Add(new Place());
}

/// <summary>
/// Clears the list of places.
/// </summary>
[TearDown]
public void ClearPlaces()
{
Expand Down
3 changes: 3 additions & 0 deletions RestAssured.Net.Tests/ResponseHeaderVerificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class ResponseHeaderVerificationTests : TestBase
private string headerName;
private string headerValue;

/// <summary>
/// Initializes the header name and value to be used in the tests.
/// </summary>
[SetUp]
public void InitializeHeaderNameAndValue()
{
Expand Down
7 changes: 6 additions & 1 deletion RestAssured.Net.Tests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// </copyright>
namespace RestAssured.Tests
{
using System;
using System.Collections.Generic;
using NUnit.Framework;
using RestAssured.Tests.Models;
Expand All @@ -31,8 +30,14 @@ public class TestBase
/// </summary>
protected WireMockServer Server { get; private set; }

/// <summary>
/// The port used by the WireMock mock server.
/// </summary>
protected static readonly int MOCK_SERVER_PORT = 9876;

/// <summary>
/// The base URL used by the WireMock mock server.
/// </summary>
protected static readonly string MOCK_SERVER_BASE_URL = $"http://localhost:{MOCK_SERVER_PORT}";

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions RestAssured.Net.Tests/TimeoutTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public class TimeoutTests : TestBase
public void CreateRequestSpecifications()
{
this.requestSpecification = new RequestSpecBuilder()
.WithScheme("http")
.WithHostName("localhost")
.WithBaseUri("http://localhost")
.WithPort(9876)
.WithTimeout(TimeSpan.FromSeconds(2))
.Build();
Expand Down
3 changes: 1 addition & 2 deletions RestAssured.Net.Tests/UserAgentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public class UserAgentTests : TestBase
public void CreateRequestSpecifications()
{
this.requestSpecification = new RequestSpecBuilder()
.WithScheme("http")
.WithHostName("localhost")
.WithBaseUri("http://localhost")
.WithPort(9876)
.WithUserAgent(new ProductInfoHeaderValue("MyUserAgent", "1.0"))
.Build();
Expand Down

0 comments on commit 0bf817e

Please sign in to comment.