46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
|
using INetMock.Client.PCAP;
|
||
|
using INetMock.Client.PCAP.Client;
|
||
|
using Xunit;
|
||
|
using Xunit.Abstractions;
|
||
|
|
||
|
namespace INetMock.Client.IntegrationTest.PCAP.Client
|
||
|
{
|
||
|
public class PcapApiClientTests : IClassFixture<INetMockServerFixture>
|
||
|
{
|
||
|
private readonly ITestOutputHelper _outputHelper;
|
||
|
private readonly IPcapApiClient _apiClient;
|
||
|
|
||
|
public PcapApiClientTests(ITestOutputHelper testOutputHelper, INetMockServerFixture inetmockFixture)
|
||
|
{
|
||
|
_outputHelper = testOutputHelper;
|
||
|
_apiClient = new PcapApiClient(inetmockFixture.SocketPath);
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public async void ListAvailableDevicesAsync_RunningContainer_AtLeastLoopbackDevice()
|
||
|
{
|
||
|
var devs = await _apiClient.ListAvailableDevicesAsync();
|
||
|
|
||
|
Assert.Contains(devs, device => device.Name.Equals("lo"));
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public async void ListActiveRecordingsAsync_NoRecordingsRunning_EmptyResult()
|
||
|
{
|
||
|
var recordings = await _apiClient.ListActiveRecordingsAsync();
|
||
|
|
||
|
Assert.Empty(recordings);
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public async void StartPcapFileRecordingAsync_RecordLoopbackInterface_RunningRecording()
|
||
|
{
|
||
|
const string targetPath = "/tmp/lo_record.pcap";
|
||
|
await _apiClient.StartPcapFileRecordingAsync(new("lo", targetPath));
|
||
|
|
||
|
var subscriptions = await _apiClient.ListActiveRecordingsAsync();
|
||
|
Assert.Contains(subscriptions, subscription => subscription.Device.Equals("lo") && subscription.ConsumerName.Equals(targetPath));
|
||
|
}
|
||
|
}
|
||
|
}
|