コード例 #1
0
        /// <summary>
        /// Read a field that contains a list of decimals.
        /// </summary>
        public IReadOnlyList <decimal> GetDecimalList(string key)
        {
            try
            {
                if (!_inner.HasKey(key))
                {
                    return(null);
                }

                return(_inner.GetDecimalList(key));
            }
            catch (NullReferenceException)
            {
                return(null);
            }
        }
コード例 #2
0
        public void Test_GetDecimalList(string json, int?expectCount, double?expectFirst)
        {
            IObjectReader           reader = GetReader(json);
            IReadOnlyList <decimal> list   = reader.GetDecimalList("a");

            if (expectCount == null)
            {
                Assert.That(list, Is.Null);
                return;
            }
            else
            {
                decimal?expectDecimal = null;
                if (expectFirst != null)
                {
                    expectDecimal = (decimal)expectFirst.Value;
                }
                Assert.That(list.Count, Is.EqualTo(expectCount));
                if (expectCount > 0)
                {
                    Assert.That(list[0], Is.EqualTo(expectFirst));
                }
            }
        }
コード例 #3
0
        public void Test_GetDecimalList_FormatException(string json)
        {
            IObjectReader reader = GetReader(json);

            Assert.Throws <FormatException>(() => reader.GetDecimalList("a"));
        }