public void TryParse_Invalid(string input) { var succeeded = Id6.TryParse(input, out var result); Assert.False(succeeded); Assert.Equal(0UL, result); }
public void TryParse_Valid(string input, ulong expected) { var succeeded = Id6.TryParse(input, out var result); Assert.True(succeeded); Assert.True(expected == result, $"{result:x16} does not equal the expected value of {expected:x16}."); }
public void Write_Fails_BecauseNullUri() { _ = Id6.TryParse("b827:ebff:fee1:e39a", out var stationId6); var stationEui = new StationEui(stationId6); Assert.Throws <ArgumentNullException>(() => Json.Write(w => LnsDiscovery.WriteResponse(w, stationEui, ValidMuxs, null))); }
public void Write_Fails_BecauseOfNonId6Muxs() { var muxs = "000000FFFE000000"; _ = Id6.TryParse("b827:ebff:fee1:e39a", out var stationId6); var stationEui = new StationEui(stationId6); Assert.Throws <ArgumentException>(() => _ = Json.Write(w => LnsDiscovery.WriteResponse(w, stationEui, muxs, new Uri(ValidUrlString)))); }
public void Write_Succeeds(string stationId6, string muxs, string routerDataEndpoint, string expected) { var stationEui = stationId6.Contains(':', StringComparison.Ordinal) ? Id6.TryParse(stationId6, out var id6) ? new StationEui(id6) : throw new JsonException() : Hexadecimal.TryParse(stationId6, out ulong hhd, '-') ? new StationEui(hhd) : throw new JsonException(); var computed = Json.Stringify(w => LnsDiscovery.WriteResponse(w, stationEui, muxs, new Uri(routerDataEndpoint))); Assert.Equal(expected, computed); }
public void Format(Id6.FormatOptions options, ulong input, string expected) { Assert.Equal(expected, Id6.Format(input, options)); }