Пример #1
0
        public void ObjectThrowsError()
        {
            var rule = new BooleanCastRule(JsonDocument.Parse("{}").RootElement);

            Assert.Throws <JsonLogicException>(() => rule.Apply());
        }
Пример #2
0
        public void EmptyArrayIsFalse()
        {
            var rule = new BooleanCastRule(JsonDocument.Parse("[]").RootElement);

            JsonAssert.IsFalse(rule.Apply());
        }
Пример #3
0
        public void TrueIsTrue()
        {
            var rule = new BooleanCastRule(true);

            JsonAssert.IsTrue(rule.Apply());
        }
Пример #4
0
        public void NullIsFalse()
        {
            var rule = new BooleanCastRule(JsonDocument.Parse("null").RootElement);

            JsonAssert.IsFalse(rule.Apply());
        }
Пример #5
0
        public void FalseIsFalse()
        {
            var rule = new BooleanCastRule(false);

            JsonAssert.IsFalse(rule.Apply());
        }
Пример #6
0
        public void NonZeroIsTrue()
        {
            var rule = new BooleanCastRule(1);

            JsonAssert.IsTrue(rule.Apply());
        }
Пример #7
0
        public void ZeroIsFalse()
        {
            var rule = new BooleanCastRule(0);

            JsonAssert.IsFalse(rule.Apply());
        }
Пример #8
0
        public void NonEmptyStringIsTrue()
        {
            var rule = new BooleanCastRule("foo");

            JsonAssert.IsTrue(rule.Apply());
        }
Пример #9
0
        public void EmptyStringIsFalse()
        {
            var rule = new BooleanCastRule("");

            JsonAssert.IsFalse(rule.Apply());
        }