示例#1
0
        public void JToken_BooleanFormatter_Handles()
        {
            var formatter = new BooleanJTokenFormatter();

            var result = formatter.Handles(SampleTokens.TrueBool.Token.Type);

            Assert.True(result, "JToken boolean formatter should handle token bool");

            result = formatter.Handles(SampleTokens.FalseBool.Token.Type);
            Assert.True(result, "JToken boolean formatter should handle token bool");

            result = formatter.Handles(SampleTokens.String.Token.Type);
            Assert.False(result, "JToken boolean formatter should not handle string types");

            result = formatter.Handles(SampleTokens.Guid.Token.Type);
            Assert.False(result, "JToken boolean formatter should not handle guid types");

            result = formatter.Handles(SampleTokens.Int.Token.Type);
            Assert.False(result, "JToken boolean formatter should not handle integer types");

            result = formatter.Handles(SampleTokens.Double.Token.Type);
            Assert.False(result, "JToken boolean formatter should not handle float types");

            result = formatter.Handles(SampleTokens.TestObject.Token.Type);
            Assert.False(result, "JToken boolean formatter should not handle object types");
        }
示例#2
0
        public void JToken_BooleanFormatter_Formatting()
        {
            var formatter = new BooleanJTokenFormatter();

            var result = formatter.Format(SampleTokens.TrueBool.Token, 0);

            Assert.Single(result);
            Assert.True(result.ContainsKey(string.Empty), "Should have a single, empty key");
            Assert.Equal("true", result[string.Empty]);

            result = formatter.Format(SampleTokens.FalseBool.Token, 0);

            Assert.Single(result);
            Assert.True(result.ContainsKey(string.Empty), "Should have a single, empty key");
            Assert.Equal("false", result[string.Empty]);
        }