Exemplo n.º 1
0
        public void TryParse_Invalid(string input)
        {
            var succeeded = Id6.TryParse(input, out var result);

            Assert.False(succeeded);
            Assert.Equal(0UL, result);
        }
Exemplo n.º 2
0
        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}.");
        }
Exemplo n.º 3
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)));
        }
Exemplo n.º 4
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))));
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 public void Format(Id6.FormatOptions options, ulong input, string expected)
 {
     Assert.Equal(expected, Id6.Format(input, options));
 }