Added IPAddress.Increment/Decrement; Added ParseNetwork, ExpandNetwork
This commit is contained in:
67
UnitTests/Common/Extensions/IPAddressExtensionsTests.cs
Normal file
67
UnitTests/Common/Extensions/IPAddressExtensionsTests.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace UnitTests.Common.Extensions
|
||||
{
|
||||
[TestClass]
|
||||
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||
public class IPAddressExtensionsTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void ShouldIncrementLastByte()
|
||||
{
|
||||
// arrange
|
||||
var ipAddress = IPAddress.Parse("192.168.178.22");
|
||||
|
||||
// act
|
||||
var incremented = ipAddress.Increment();
|
||||
|
||||
// assert
|
||||
Assert.AreEqual("192.168.178.23", incremented.ToString());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ShouldIncrementAllBytes()
|
||||
{
|
||||
// arrange
|
||||
var ipAddress = IPAddress.Parse("192.255.255.255");
|
||||
|
||||
// act
|
||||
var incremented = ipAddress.Increment();
|
||||
|
||||
// assert
|
||||
Assert.AreEqual("193.0.0.0", incremented.ToString());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ShouldDecrementLastByte()
|
||||
{
|
||||
// arrange
|
||||
var ipAddress = IPAddress.Parse("192.168.178.22");
|
||||
|
||||
// act
|
||||
var decremented = ipAddress.Decrement();
|
||||
|
||||
// assert
|
||||
Assert.AreEqual("192.168.178.21", decremented.ToString());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ShouldDecrementAllBytes()
|
||||
{
|
||||
// arrange
|
||||
var ipAddress = IPAddress.Parse("192.0.0.0");
|
||||
|
||||
// act
|
||||
var decremented = ipAddress.Decrement();
|
||||
|
||||
// assert
|
||||
Assert.AreEqual("191.255.255.255", decremented.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user