public void ItShouldCreateLogFile() { // Arrange var interfaces = new[] { CreateInterface("interface1"), CreateInterface("interface2"), }; _networkInterfaces.Interfaces().Returns(interfaces); var log = new NetworkAdapterLog(_networkInterfaces, TmpPath); // Act log.Write(); // Assert var path = Path.Combine(TmpPath, "NetworkAdapters.txt"); File.Exists(path).Should().BeTrue(); var content = File.ReadAllText(path); content.Should().Contain("interface1"); content.Should().Contain("interface2"); }
private void NetworkInterfaces_NetworkAddressChanged(object sender, EventArgs e) { var adapters = _networkInterfaces.Interfaces(); if (!adapters.Any()) { return; } var list = adapters.Where(a => !a.IsLoopback).Select(a => a.Id).ToList(); if (list.Except(_interfaces).Any()) { NetworkInterfacesAdded?.Invoke(this, EventArgs.Empty); } _interfaces = list; }