Skip to content

Commit

Permalink
Add property 'IsStartedWithAdminInterface' to 'IWireMockServer' (#931)
Browse files Browse the repository at this point in the history
* Add property 'IsStartedWithAdminInterface' to 'IWireMockServer'

* update tests

* .
  • Loading branch information
StefH authored May 6, 2023
1 parent ccd8026 commit d29f3e8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/WireMock.Net.Abstractions/Server/IWireMockServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public interface IWireMockServer : IDisposable
/// </summary>
bool IsStarted { get; }

/// <summary>
/// Gets a value indicating whether this server is started with the admin interface enabled.
/// </summary>
bool IsStartedWithAdminInterface { get; }

/// <summary>
/// Gets the request logs.
/// </summary>
Expand Down
6 changes: 5 additions & 1 deletion src/WireMock.Net/Server/WireMockServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ public partial class WireMockServer : IWireMockServer
private readonly IGuidUtils _guidUtils = new GuidUtils();
private readonly IDateTimeUtils _dateTimeUtils = new DateTimeUtils();

/// <inheritdoc cref="IWireMockServer.IsStarted" />
/// <inheritdoc />
[PublicAPI]
public bool IsStarted => _httpServer is { IsStarted: true };

/// <inheritdoc />
[PublicAPI]
public bool IsStartedWithAdminInterface => IsStarted && _settings.StartAdminInterface.GetValueOrDefault();

/// <inheritdoc />
[PublicAPI]
public List<int> Ports { get; }
Expand Down
26 changes: 26 additions & 0 deletions test/WireMock.Net.Tests/WireMockServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,32 @@ public WireMockServerTests(ITestOutputHelper testOutputHelper)
_testOutputHelper = testOutputHelper;
}

[Fact]
public void WireMockServer_Start()
{
// Act
var server = WireMockServer.Start();

// Assert
server.IsStarted.Should().BeTrue();
server.IsStartedWithAdminInterface.Should().BeFalse();

server.Stop();
}

[Fact]
public void WireMockServer_StartWithAdminInterface()
{
// Act
var server = WireMockServer.StartWithAdminInterface();

// Assert
server.IsStarted.Should().BeTrue();
server.IsStartedWithAdminInterface.Should().BeTrue();

server.Stop();
}

[Fact]
public async Task WireMockServer_Should_Reset_LogEntries()
{
Expand Down

0 comments on commit d29f3e8

Please sign in to comment.