Updated core unit tests to latest recommendations

This commit is contained in:
2025-08-07 17:12:42 +02:00
parent 90d8320abc
commit 09e3c8ce48
11 changed files with 267 additions and 295 deletions

View File

@@ -2,7 +2,7 @@
using System.Net.Http;
using AMWD.Net.Api.Cloudflare;
namespace Cloudflare.Core.Tests.Auth
namespace Cloudflare.Tests.Auth
{
[TestClass]
public class ApiKeyAuthenticationTest
@@ -32,48 +32,39 @@ namespace Cloudflare.Core.Tests.Auth
[DataRow(null)]
[DataRow("")]
[DataRow(" ")]
[ExpectedException(typeof(ArgumentNullException))]
public void ShouldArgumentNullExceptionForEmailAddress(string emailAddress)
{
// Arrange
string apiKey = "some-api-key";
// Act
new ApiKeyAuthentication(emailAddress, apiKey);
// Assert - ArgumentNullException
// Act & Assert
Assert.ThrowsExactly<ArgumentNullException>(() => new ApiKeyAuthentication(emailAddress, apiKey));
}
[TestMethod]
[DataRow(null)]
[DataRow("")]
[DataRow(" ")]
[ExpectedException(typeof(ArgumentNullException))]
public void ShouldArgumentNullExceptionForApiKey(string apiKey)
{
// Arrange
string emailAddress = "test@example.com";
// Act
new ApiKeyAuthentication(emailAddress, apiKey);
// Assert - ArgumentNullException
// Act & Assert
Assert.ThrowsExactly<ArgumentNullException>(() => new ApiKeyAuthentication(emailAddress, apiKey));
}
[TestMethod]
[DataRow("test")]
[DataRow("test@example")]
[DataRow("example.com")]
[ExpectedException(typeof(ArgumentException))]
public void ShouldArgumentExceptionForInvalidEmailAddress(string emailAddress)
{
// Arrange
string apiKey = "some-api-key";
// Act
new ApiKeyAuthentication(emailAddress, apiKey);
// Assert - ArgumentException
// Act & Assert
Assert.ThrowsExactly<ArgumentException>(() => new ApiKeyAuthentication(emailAddress, apiKey));
}
}
}

View File

@@ -1,7 +1,7 @@
using System.Net.Http;
using AMWD.Net.Api.Cloudflare;
namespace Cloudflare.Core.Tests.Auth
namespace Cloudflare.Tests.Auth
{
[TestClass]
public class ApiTokenAuthenticationTest
@@ -29,15 +29,12 @@ namespace Cloudflare.Core.Tests.Auth
[DataRow(null)]
[DataRow("")]
[DataRow(" ")]
[ExpectedException(typeof(ArgumentNullException))]
public void ShouldArgumentNullExceptionForEmailAddress(string apiToken)
{
// Arrange
// Act
new ApiTokenAuthentication(apiToken);
// Assert - ArgumentNullException
// Act & Assert
Assert.ThrowsExactly<ArgumentNullException>(() => new ApiTokenAuthentication(apiToken));
}
}
}