Esempio n. 1
0
        public static JElement ShouldBeAJsonValue(this JElement element, ElementType type, object value = null)
        {
            element.ShouldBeAJsonValue();

            if (type == ElementType.Null)
            {
                type.ShouldEqual(ElementType.Null);
                element.Value.ShouldBeNull();
            }
            else type.ShouldNotEqual(ElementType.Null);

            if (type == ElementType.String)
            {
                type.ShouldEqual(ElementType.String);
                element.Value.ShouldEqual(value);
            }
            else type.ShouldNotEqual(ElementType.String);

            if (type == ElementType.Number)
            {
                type.ShouldEqual(ElementType.Number);
                Convert.ToDecimal(element.Value).ShouldEqual(Convert.ToDecimal(value));
            }
            else type.ShouldNotEqual(ElementType.Number);

            if (type == ElementType.Boolean)
            {
                type.ShouldEqual(ElementType.Boolean);
                element.Value.ShouldEqual(value);
            }
            else type.ShouldNotEqual(ElementType.Boolean);

            return element;
        }