public void LocalIpAddress_CurrentMachine_NotEmpty() { var ipAddressRenderer = new LocalIpAddressLayoutRenderer(); var result = ipAddressRenderer.Render(LogEventInfo.CreateNullEvent()); Assert.NotEmpty(result); }
public void LocalIpAddress_CurrentMachine_NotEmpty() { if (IsTravis()) { Console.WriteLine("[SKIP] NetworkIpAddressLayoutRendererTests.LocalIpAddress_CurrentMachine_NotEmpty because we are running in Travis"); return; } var ipAddressRenderer = new LocalIpAddressLayoutRenderer(); var result = ipAddressRenderer.Render(LogEventInfo.CreateNullEvent()); Assert.NotEmpty(result); }
public void LocalIpAddress_RetrieverThrowsException_RenderEmptyString() { var networkInterfaceRetrieverMock = Substitute.For <INetworkInterfaceRetriever>(); networkInterfaceRetrieverMock.AllNetworkInterfaces.Throws(new Exception("oops")); var ipAddressRenderer = new LocalIpAddressLayoutRenderer(networkInterfaceRetrieverMock); // Act var result = ipAddressRenderer.Render(LogEventInfo.CreateNullEvent()); // Assert Assert.Equal(string.Empty, result); }
public void LocalIpAddress_OneInterfaceWithMultipleIps_RendersFirstIp() { // Arrange var networkInterfaceRetrieverMock = new NetworkInterfaceRetrieverBuilder() .WithInterface(NetworkInterfaceType.Ethernet, Mac1) .WithIp("10.0.1.1") .WithIp("10.0.1.2") .WithIp("10.0.1.3") .Build(); var ipAddressRenderer = new LocalIpAddressLayoutRenderer(networkInterfaceRetrieverMock); // Act var result = ipAddressRenderer.Render(LogEventInfo.CreateNullEvent()); // Assert Assert.Equal("10.0.1.1", result); }
public void LocalIpAddress_RendersSuccessfulIp() { // Arrange var ipString = "10.0.1.2"; var networkInterfaceRetrieverMock = new NetworkInterfaceRetrieverBuilder() .WithInterface(NetworkInterfaceType.Ethernet, Mac1) .WithIp(ipString) .Build(); var ipAddressRenderer = new LocalIpAddressLayoutRenderer(networkInterfaceRetrieverMock); // Act var result = ipAddressRenderer.Render(LogEventInfo.CreateNullEvent()); // Assert Assert.Equal(ipString, result); }
public void LocalIpAddress_SkipsLoopback() { // Arrange var networkInterfaceRetrieverMock = new NetworkInterfaceRetrieverBuilder() .WithInterface(NetworkInterfaceType.Loopback, "F0-E0-D2-C3-B4-A5") .WithIp("1.2.3.4") .WithInterface(NetworkInterfaceType.Ethernet, Mac1) .WithIp("10.0.1.2") .Build(); var ipAddressRenderer = new LocalIpAddressLayoutRenderer(networkInterfaceRetrieverMock); // Act var result = ipAddressRenderer.Render(LogEventInfo.CreateNullEvent()); // Assert Assert.Equal("10.0.1.2", result); }
public void LocalIpAddress_Multiple_TakesFirstIpv4() { // Arrange var ipString = "10.0.1.2"; var networkInterfaceRetrieverMock = new NetworkInterfaceRetrieverBuilder() .WithInterface(NetworkInterfaceType.Ethernet, "F0-E0-D2-C3-B4-A5") .WithIp("fe80:0:0:0:200:f8ff:fe21:67cf") .WithInterface(NetworkInterfaceType.Ethernet, Mac1) .WithIp(ipString) .Build(); var ipAddressRenderer = new LocalIpAddressLayoutRenderer(networkInterfaceRetrieverMock); // Act var result = ipAddressRenderer.Render(LogEventInfo.CreateNullEvent()); // Assert Assert.Equal(ipString, result); }
public void LocalIpAddress_Multiple_TakesFirstWithGatewayUp() { // Arrange var networkInterfaceRetrieverMock = new NetworkInterfaceRetrieverBuilder() .WithInterface(NetworkInterfaceType.Ethernet, "F0-E0-D2-C3-B4-A5", OperationalStatus.Dormant) .WithIp("10.0.1.1", "10.0.1.0") .WithInterface(NetworkInterfaceType.Ethernet, Mac1, OperationalStatus.Up) .WithIp("10.0.1.2") .WithInterface(NetworkInterfaceType.Ethernet, Mac1, OperationalStatus.Up) .WithIp("10.0.1.3", "10.0.1.0") .Build(); var ipAddressRenderer = new LocalIpAddressLayoutRenderer(networkInterfaceRetrieverMock); // Act var result = ipAddressRenderer.Render(LogEventInfo.CreateNullEvent()); // Assert Assert.Equal("10.0.1.3", result); }
public void LocalIpAddress_Multiple_TakesFirstIpv6IfRequested() { // Arrange var ipv6 = "fe80::200:f8ff:fe21:67cf"; var networkInterfaceRetrieverMock = new NetworkInterfaceRetrieverBuilder() .WithInterface(NetworkInterfaceType.Ethernet, "F0-E0-D2-C3-B4-A5") .WithIp("1.0.10.11") .WithInterface(NetworkInterfaceType.Ethernet, Mac1) .WithIp(ipv6) .Build(); var ipAddressRenderer = new LocalIpAddressLayoutRenderer(networkInterfaceRetrieverMock) { AddressFamily = AddressFamily.InterNetworkV6 }; // Act var result = ipAddressRenderer.Render(LogEventInfo.CreateNullEvent()); // Assert Assert.Equal(ipv6, result); }