mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 19:18:46 +00:00
Capitalize IP acronym
This commit is contained in:
parent
99bdbccf85
commit
1f9bbe9319
43
X10D.Tests/src/Net/IPAddressTests.cs
Normal file
43
X10D.Tests/src/Net/IPAddressTests.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Net;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using X10D.Net;
|
||||
|
||||
namespace X10D.Tests.Net;
|
||||
|
||||
[TestClass]
|
||||
public class IPAddressTests
|
||||
{
|
||||
private IPAddress _ipv4Address = null!;
|
||||
private IPAddress _ipv6Address = null!;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_ipv4Address = IPAddress.Parse("127.0.0.1");
|
||||
_ipv6Address = IPAddress.Parse("::1");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsIPv4_ShouldBeTrue_GivenIPv4()
|
||||
{
|
||||
Assert.IsTrue(_ipv4Address.IsIPv4());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsIPv4_ShouldBeFalse_GivenIPv6()
|
||||
{
|
||||
Assert.IsFalse(_ipv6Address.IsIPv4());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsIPv6_ShouldBeFalse_GivenIPv4()
|
||||
{
|
||||
Assert.IsFalse(_ipv4Address.IsIPv6());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsIPv6_ShouldBeTrue_GivenIPv6()
|
||||
{
|
||||
Assert.IsTrue(_ipv6Address.IsIPv6());
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
using System.Net;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using X10D.Net;
|
||||
|
||||
namespace X10D.Tests.Net;
|
||||
|
||||
[TestClass]
|
||||
public class IpAddressTests
|
||||
{
|
||||
private IPAddress _ipv4Address = null!;
|
||||
private IPAddress _ipv6Address = null!;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_ipv4Address = IPAddress.Parse("127.0.0.1");
|
||||
_ipv6Address = IPAddress.Parse("::1");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsIPv4()
|
||||
{
|
||||
Assert.IsTrue(_ipv4Address.IsIpV4());
|
||||
Assert.IsFalse(_ipv6Address.IsIpV4());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsIPv6()
|
||||
{
|
||||
Assert.IsTrue(_ipv6Address.IsIpV6());
|
||||
Assert.IsFalse(_ipv4Address.IsIpV6());
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ namespace X10D.Net;
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="IPAddress" />.
|
||||
/// </summary>
|
||||
public static class IpAddressExtensions
|
||||
public static class IPAddressExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a value indicating whether the specified IP address is a valid IPv4 address.
|
||||
@ -15,7 +15,7 @@ public static class IpAddressExtensions
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if the specified IP address is a valid IPv4 address; otherwise, <see langword="false" />.
|
||||
/// </returns>
|
||||
public static bool IsIpV4(this IPAddress address)
|
||||
public static bool IsIPv4(this IPAddress address)
|
||||
{
|
||||
return address.AddressFamily == AddressFamily.InterNetwork;
|
||||
}
|
||||
@ -27,7 +27,7 @@ public static class IpAddressExtensions
|
||||
/// <returns>
|
||||
/// <see langword="true" /> if the specified IP address is a valid IPv6 address; otherwise, <see langword="false" />.
|
||||
/// </returns>
|
||||
public static bool IsIpV6(this IPAddress address)
|
||||
public static bool IsIPv6(this IPAddress address)
|
||||
{
|
||||
return address.AddressFamily == AddressFamily.InterNetworkV6;
|
||||
}
|
Loading…
Reference in New Issue
Block a user