예제 #1
0
        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)));
        }
예제 #2
0
        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))));
        }
예제 #3
0
        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);
        }