-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
146 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("WireMock.Net.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e138ec44d93acac565953052636eb8d5e7e9f27ddb030590055cd1a0ab2069a5623f1f77ca907d78e0b37066ca0f6d63da7eecc3fcb65b76aa8ebeccf7ebe1d11264b8404cd9b1cbbf2c83f566e033b3e54129f6ef28daffff776ba7aebbc53c0d635ebad8f45f78eb3f7e0459023c218f003416e080f96a1a3c5ffeb56bee9e")] | ||
|
||
// Needed for Moq in the UnitTest project | ||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] |
134 changes: 134 additions & 0 deletions
134
test/WireMock.Net.Tests/Aspire/WireMockServerArgumentsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#if NET8_0_OR_GREATER | ||
using Aspire.Hosting; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace WireMock.Net.Tests.Aspire; | ||
|
||
public class WireMockServerArgumentsTests | ||
{ | ||
[Fact] | ||
public void DefaultValues_ShouldBeSetCorrectly() | ||
{ | ||
// Arrange & Act | ||
var args = new WireMockServerArguments(); | ||
|
||
// Assert | ||
args.Port.Should().Be(WireMockServerArguments.DefaultPort); | ||
args.AdminUsername.Should().BeNull(); | ||
args.AdminPassword.Should().BeNull(); | ||
args.ReadStaticMappings.Should().BeFalse(); | ||
args.WithWatchStaticMappings.Should().BeFalse(); | ||
args.MappingsPath.Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void HasBasicAuthentication_ShouldReturnTrue_WhenUsernameAndPasswordAreProvided() | ||
{ | ||
// Arrange | ||
var args = new WireMockServerArguments | ||
{ | ||
AdminUsername = "admin", | ||
AdminPassword = "password" | ||
}; | ||
|
||
// Act & Assert | ||
args.HasBasicAuthentication.Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void HasBasicAuthentication_ShouldReturnFalse_WhenEitherUsernameOrPasswordIsNotProvided() | ||
{ | ||
// Arrange | ||
var argsWithUsernameOnly = new WireMockServerArguments { AdminUsername = "admin" }; | ||
var argsWithPasswordOnly = new WireMockServerArguments { AdminPassword = "password" }; | ||
|
||
// Act & Assert | ||
argsWithUsernameOnly.HasBasicAuthentication.Should().BeFalse(); | ||
argsWithPasswordOnly.HasBasicAuthentication.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void GetArgs_WhenReadStaticMappingsIsTrue_ShouldContainReadStaticMappingsTrue() | ||
{ | ||
// Arrange | ||
var args = new WireMockServerArguments | ||
{ | ||
ReadStaticMappings = true | ||
}; | ||
|
||
// Act | ||
var commandLineArgs = args.GetArgs(); | ||
|
||
// Assert | ||
commandLineArgs.Should().ContainInOrder("--ReadStaticMappings", "true"); | ||
} | ||
|
||
[Fact] | ||
public void GetArgs_WhenReadStaticMappingsIsFalse_ShouldNotContainReadStaticMappingsTrue() | ||
{ | ||
// Arrange | ||
var args = new WireMockServerArguments | ||
{ | ||
ReadStaticMappings = false | ||
}; | ||
|
||
// Act | ||
var commandLineArgs = args.GetArgs(); | ||
|
||
// Assert | ||
commandLineArgs.Should().NotContain("--ReadStaticMappings", "true"); | ||
} | ||
|
||
[Fact] | ||
public void GetArgs_WhenWithWatchStaticMappingsIsTrue_ShouldContainWatchStaticMappingsTrue() | ||
{ | ||
// Arrange | ||
var args = new WireMockServerArguments | ||
{ | ||
WithWatchStaticMappings = true, | ||
ReadStaticMappings = false // This needs to be false to check the independent effect of WithWatchStaticMappings | ||
}; | ||
|
||
// Act | ||
var commandLineArgs = args.GetArgs(); | ||
|
||
// Assert | ||
commandLineArgs.Should().ContainInOrder("--ReadStaticMappings", "true", "--WatchStaticMappings", "true", "--WatchStaticMappingsInSubdirectories", "true"); | ||
} | ||
|
||
[Fact] | ||
public void GetArgs_WhenWithWatchStaticMappingsIsFalse_ShouldNotContainWatchStaticMappingsTrue() | ||
{ | ||
// Arrange | ||
var args = new WireMockServerArguments | ||
{ | ||
WithWatchStaticMappings = false | ||
}; | ||
|
||
// Act | ||
var commandLineArgs = args.GetArgs(); | ||
|
||
// Assert | ||
commandLineArgs.Should().NotContain("--WatchStaticMappings", "true").And.NotContain("--WatchStaticMappingsInSubdirectories", "true"); | ||
} | ||
|
||
[Fact] | ||
public void GetArgs_ShouldIncludeAuthenticationDetails_WhenAuthenticationIsRequired() | ||
{ | ||
// Arrange | ||
var args = new WireMockServerArguments | ||
{ | ||
AdminUsername = "admin", | ||
AdminPassword = "password" | ||
}; | ||
|
||
// Act | ||
var commandLineArgs = args.GetArgs(); | ||
|
||
// Assert | ||
commandLineArgs.Should().Contain("--AdminUserName", "admin"); | ||
commandLineArgs.Should().Contain("--AdminPassword", "password"); | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters