Skip to content

Commit

Permalink
Created a list of private IP addresses for use in the test.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstebo committed Nov 21, 2018
1 parent b16f08f commit 54713f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 47 deletions.
28 changes: 0 additions & 28 deletions tests/FakerDotNet.Tests/Helpers/IPRangeHelper.cs

This file was deleted.

36 changes: 17 additions & 19 deletions tests/FakerDotNet.Tests/Validators/IPv4ValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,9 @@ public void IsPublic_returns_true_for_public_ip_addresses(string ip)

[Test]
[TestCaseSource(typeof(IPRangeData), nameof(IPRangeData.PrivateIPs))]
public void IsPublic_returns_false_for_private_ip_addresses(string startIp, string endIp)
public void IsPublic_returns_false_for_private_ip_addresses(string ip)
{
// Take the first and last batch...otherwise it could take a really long time
foreach (var ip in IPRangeHelper.GetRange(startIp, endIp).Take(10))
{
Assert.IsFalse(IPv4Validator.IsPublic(ip), "Apparently {0} is a public IP", ip);
}

foreach (var ip in IPRangeHelper.GetRange(startIp, endIp).TakeLast(10))
{
Assert.IsFalse(IPv4Validator.IsPublic(ip), "Apparently {0} is a public IP", ip);
}
Assert.IsFalse(IPv4Validator.IsPublic(ip), "Apparently {0} is a public IP", ip);
}
}

Expand All @@ -44,14 +35,21 @@ public static IEnumerable PrivateIPs
{
get
{
yield return new TestCaseData("10.0.0.0", "10.255.255.255");
yield return new TestCaseData("100.64.0.0", "100.127.255.255");
yield return new TestCaseData("127.0.0.0", "127.255.255.255");
yield return new TestCaseData("169.254.0.0", "169.254.255.255");
yield return new TestCaseData("172.16.0.0", "172.31.255.255");
yield return new TestCaseData("192.0.0.0", "192.0.0.255");
yield return new TestCaseData("192.168.0.0", "192.168.255.255");
yield return new TestCaseData("198.18.0.0", "198.19.255.255");
yield return new TestCaseData("10.2.3.4");
yield return new TestCaseData("100.64.1.2");
yield return new TestCaseData("100.82.1.2");
yield return new TestCaseData("100.127.1.2");
yield return new TestCaseData("127.0.0.1");
yield return new TestCaseData("127.1.2.3");
yield return new TestCaseData("127.0.1.2");
yield return new TestCaseData("169.254.1.2");
yield return new TestCaseData("172.16.1.2");
yield return new TestCaseData("172.24.1.2");
yield return new TestCaseData("172.31.1.2");
yield return new TestCaseData("192.0.0.1");
yield return new TestCaseData("192.168.1.2");
yield return new TestCaseData("198.18.1.2");
yield return new TestCaseData("198.19.1.2");
}
}
}
Expand Down

0 comments on commit 54713f4

Please sign in to comment.