/// <summary> /// Initializes a new instance of the <see cref="ArpServiceUnitTests"/> class. /// </summary> /// <param name="testOutputHelper">The test output helper.</param> /// <autogeneratedoc /> public ArpServiceUnitTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { var commonServices = CommonServices.CreateInstance(TestLoggerFactory, "ArpServiceUnitTests"); IPingService pingService = new PingService.PingService(commonServices); _arpService = new ArpService(commonServices, pingService); }
/// <summary> /// Initializes a new instance of the <see cref="ArpServiceIntegrationTests"/> class. /// </summary> /// <param name="testOutputHelper">The test output helper.</param> /// <autogeneratedoc /> public ArpServiceIntegrationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { _commonServices = CommonServices.CreateInstance(TestLoggerFactory, "ArpServiceIntegrationTests"); IPingService pingService = new PingService.PingService(_commonServices); _arpService = new ArpService(_commonServices, pingService); _defaultGatewayIPAddressSubnet = _commonServices.NetworkingSystem.GetDefaultGatewayAddressSubnet(); }
/// <summary> /// Triggered when the application host is ready to start the service. /// </summary> /// <param name="cancellationToken">Indicates that the start process has been aborted.</param> /// <returns>Task.</returns> /// <autogeneratedoc /> public Task StartAsync(CancellationToken cancellationToken) { ServiceHostStatus = ServiceHostStatus.StartPending; var tasks = new List <Task> { CommonServices.StartAsync(cancellationToken), PingService.StartAsync(cancellationToken), ArpService.StartAsync(cancellationToken) }; return(tasks.WaitForTasks(cancellationToken, (t) => { if (t.IsCompleted && t.Status == TaskStatus.RanToCompletion) { ServiceHostStatus = ServiceHostStatus.Running; } }, Logger)); }
/// <summary> /// Triggered when the application host is performing a graceful shutdown. /// </summary> /// <param name="cancellationToken">Indicates that the shutdown process should no longer be graceful.</param> /// <returns>Task.</returns> /// <autogeneratedoc /> public Task StopAsync(CancellationToken cancellationToken) { var tasks = new List <Task> { ArpService.StopAsync(cancellationToken), PingService.StopAsync(cancellationToken), CommonServices.StopAsync(cancellationToken) }; ServiceHostStatus = ServiceHostStatus.StopPending; var logger = CommonServices?.LoggerFactory?.CreatePureLogger <CommonNetworkServices>(); return(tasks.WaitForTasks(cancellationToken, (t) => { if (t.IsCompleted) { ServiceHostStatus = ServiceHostStatus.Stopped; } } , logger)); }
public void ArpService_RunArpSync_MockEmptyResult() { var commonServicesMock = new CommonServicesMock(_commonServices, CommonServicesMock.CommonServicesToMock.ProcessRunner); var arpCommandPath = _commonServices.FileSystem.ArpCommandPath(); var args = new[] { "-a" }; commonServicesMock.CommonServicesTest.Setup(ost => ost.ProcessRunner.RunProcessAsync(arpCommandPath, args, _arpService.Timeout)) .Returns(Task.FromResult(new ProcessResult(false, string.Empty))); var arpServicesMock = new ArpService(commonServicesMock.CommonServicesTest.Object, new PingService.PingService(_commonServices)); var physicalAddress = arpServicesMock.GetPhysicalAddress(_defaultGatewayIPAddressSubnet.IPAddress); physicalAddress.Should().NotBeNull(); physicalAddress.Should().Be(PhysicalAddress.None); }