Beispiel #1
0
        public AccountLimits(string json)
        {
            var node = JSON.Parse(json);

            MaxMemory    = JsonUtils.AsLongOrMinus1(node, ApiConstants.MaxMemory);
            MaxStorage   = JsonUtils.AsLongOrMinus1(node, ApiConstants.MaxStorage);
            MaxStreams   = JsonUtils.AsLongOrMinus1(node, ApiConstants.MaxStreams);
            MaxConsumers = JsonUtils.AsLongOrMinus1(node, ApiConstants.MaxConsumers);
        }
Beispiel #2
0
        public void TestJsonUtilsAsMethods()
        {
            Assert.Equal(-1, JsonUtils.AsIntOrMinus1(testJsonNode, "notfound"));
            Assert.Equal(int.MinValue, JsonUtils.AsIntOrMinus1(testJsonNode, "imin"));
            Assert.Equal(-1, JsonUtils.AsIntOrMinus1(testJsonNode, "iminusone"));
            Assert.Equal(0, JsonUtils.AsIntOrMinus1(testJsonNode, "izero"));
            Assert.Equal(1, JsonUtils.AsIntOrMinus1(testJsonNode, "ione"));
            Assert.Equal(int.MaxValue, JsonUtils.AsIntOrMinus1(testJsonNode, "imax"));

            Assert.Equal(-1, JsonUtils.AsLongOrMinus1(testJsonNode, "notfound"));
            Assert.Equal(long.MinValue, JsonUtils.AsLongOrMinus1(testJsonNode, "lmin"));
            Assert.Equal(-1, JsonUtils.AsLongOrMinus1(testJsonNode, "lminusone"));
            Assert.Equal(0, JsonUtils.AsLongOrMinus1(testJsonNode, "lzero"));
            Assert.Equal(1, JsonUtils.AsLongOrMinus1(testJsonNode, "lone"));
            Assert.Equal(long.MaxValue, JsonUtils.AsLongOrMinus1(testJsonNode, "lmax"));

            Assert.Equal(0ul, JsonUtils.AsUlongOrZero(testJsonNode, "notfound"));
            Assert.Equal(0ul, JsonUtils.AsUlongOrZero(testJsonNode, "uzero"));
            Assert.Equal(1ul, JsonUtils.AsUlongOrZero(testJsonNode, "uone"));
            Assert.Equal(ulong.MaxValue - 1, JsonUtils.AsUlongOrZero(testJsonNode, "unotmax"));
            Assert.Equal(ulong.MaxValue, JsonUtils.AsUlongOrZero(testJsonNode, "umax"));
        }