public void TestChomp(string baseRange, string range, bool expectedResult, string expectedLeft, string expectedRight, Type expectedException = null) { bool result; IPAddressRange leftObj, rightObj; try { IPAddressRange baseRangeObj = IPAddressRange.Parse(baseRange); IPAddressRange rangeObj = IPAddressRange.Parse(range); result = baseRangeObj.Chomp(rangeObj, out leftObj, out rightObj); } catch (Exception ex) { Assert.AreEqual(ex.GetType(), expectedException); return; } if (expectedException is not null) { Assert.Fail("Failed to throw expected exception type {0}", expectedException.Name); } Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedLeft, leftObj?.ToString()); Assert.AreEqual(expectedRight, rightObj?.ToString()); }