public void GetPrefixLength_with_RewriteBeginEndProperties_Failures() { var range = new IPAddressRange(); TestContext.Run((string begin, string end, Type expectedException, string begin2, string end2, int expected) => { Console.WriteLine($"TestCase: \"{begin}\"~\"{end}\", Expected Exception: \"{expectedException.Name}\""); try { range.Begin = IPAddress.Parse(begin); range.End = IPAddress.Parse(end); range.GetPrefixLength(); Assert.Fail($"Expected exception of type {expectedException.Name} to be thrown for input \"{begin}\"~\"{end}\""); } catch (AssertFailedException) { throw; // allow Assert.Fail to pass through } catch (Exception ex) { ex.GetType().Is(expectedException); } // Once it was failed, but it will be recovered with valid begin/end property. Console.WriteLine($"TestCase: \"{begin2}\"~\"{end2}\", Expected: \"{expected}\""); range.Begin = IPAddress.Parse(begin2); range.End = IPAddress.Parse(end2); var output = range.GetPrefixLength(); Console.WriteLine($" Result: \"{output}\""); output.Is(expected); }); }
public void GetPrefixLength_with_RewriteBeginEndProperties_Success(string begin, string end, int expected) { var range = new IPAddressRange(IPAddress.Parse(begin), IPAddress.Parse(end)); Console.WriteLine($"TestCase: \"{begin}\"~\"{end}\", Expected: \"{expected}\""); var output = range.GetPrefixLength(); Console.WriteLine($" Result: \"{output}\""); output.Is(expected); }