コード例 #1
0
        public void ReadAsDecimalFailure()
        {
            ExceptionAssert.Throws<JSchemaException>(() =>
            {
                JSchema s = new JSchemaGenerator().Generate(typeof(decimal));
                s.MultipleOf = 1;

                JsonReader reader = new JSchemaValidatingReader(new JsonTextReader(new StringReader(@"5.5")))
                {
                    Schema = s
                };
                reader.ReadAsDecimal();
            }, "Float 5.5 is not a multiple of 1. Path '', line 1, position 3.");
        }
コード例 #2
0
        public void ReadAsDecimal()
        {
            JSchema s = new JSchemaGenerator().Generate(typeof(decimal));

            JsonReader reader = new JSchemaValidatingReader(new JsonTextReader(new StringReader(@"1.5")))
            {
                Schema = s
            };
            decimal? d = reader.ReadAsDecimal();

            Assert.AreEqual(1.5m, d);
        }