当前位置: 首页>>代码示例>>C#>>正文


C# JsonSchema4类代码示例

本文整理汇总了C#中JsonSchema4的典型用法代码示例。如果您正苦于以下问题:C# JsonSchema4类的具体用法?C# JsonSchema4怎么用?C# JsonSchema4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JsonSchema4类属于命名空间,在下文中一共展示了JsonSchema4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: When_format_date_time_correct_then_validation_succeeds

        public void When_format_date_time_correct_then_validation_succeeds()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.String;
            schema.Format = JsonFormatStrings.DateTime;

            var token = new JValue("2014-12-01 11:00:01");

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(0, errors.Count());
        }
开发者ID:vmaramreddy1,项目名称:NJsonSchema,代码行数:15,代码来源:FormatDateTimeTests.cs

示例2: ClassTemplateModel

        public ClassTemplateModel(string typeName, CSharpGeneratorSettings settings, CSharpTypeResolver resolver, JsonSchema4 schema, IEnumerable<PropertyModel> properties)
        {
            _resolver = resolver;
            _schema = schema;
            _settings = settings;

            Class = typeName;
            Properties = properties;
        }
开发者ID:tomstreet,项目名称:NJsonSchema,代码行数:9,代码来源:ClassTemplateModel.cs

示例3: When_adding_property_to_schema_then_parent_should_be_set

        public void When_adding_property_to_schema_then_parent_should_be_set()
        {
            //// Arrange
            var schema = new JsonSchema4();

            //// Act
            schema.Properties.Add("test", new JsonProperty());

            //// Assert
            Assert.IsTrue(schema.Properties.ContainsKey("test"));
            Assert.AreEqual(schema, schema.Properties["test"].ParentSchema);
        }
开发者ID:vmaramreddy1,项目名称:NJsonSchema,代码行数:12,代码来源:JsonSchemaTests.cs

示例4: When_boolean_required_but_string_provided_then_validation_fails

        public void When_boolean_required_but_string_provided_then_validation_fails()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.Boolean;

            var token = new JValue("foo");

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(ValidationErrorKind.BooleanExpected, errors.First().Kind);
        }
开发者ID:prateekguru,项目名称:NJsonSchema,代码行数:14,代码来源:ValueTypeValidationTests.cs

示例5: When_integer_required_and_integer_provided_then_validation_succeeds

        public void When_integer_required_and_integer_provided_then_validation_succeeds()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.Integer;

            var token = new JValue(10);

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(0, errors.Count());
        }
开发者ID:prateekguru,项目名称:NJsonSchema,代码行数:14,代码来源:ValueTypeValidationTests.cs

示例6: When_integer_minimum_does_not_match_then_it_should_fail

        public void When_integer_minimum_does_not_match_then_it_should_fail()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.Integer;
            schema.Minimum = 2;

            var token = new JValue(1);

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(ValidationErrorKind.NumberTooSmall, errors.First().Kind);
        }
开发者ID:prateekguru,项目名称:NJsonSchema,代码行数:15,代码来源:ValueTypeValidationTests.cs

示例7: When_format_hostname_is_ip_then_validation_succeeds

        public void When_format_hostname_is_ip_then_validation_succeeds()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.String;
            schema.Format = JsonFormatStrings.Hostname;

            var token = new JValue("rsuter.com");

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(0, errors.Count());
        }
开发者ID:vmaramreddy1,项目名称:NJsonSchema,代码行数:15,代码来源:FormatHostnameTests.cs

示例8: When_format_hostname_incorrect_then_validation_succeeds

        public void When_format_hostname_incorrect_then_validation_succeeds()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.String;
            schema.Format = JsonFormatStrings.Hostname;

            var token = new JValue("foo:bar");

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(ValidationErrorKind.HostnameExpected, errors.First().Kind);
        }
开发者ID:vmaramreddy1,项目名称:NJsonSchema,代码行数:15,代码来源:FormatHostnameTests.cs

示例9: When_format_ipv6_incorrect_then_validation_fails

        public void When_format_ipv6_incorrect_then_validation_fails()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.String;
            schema.Format = JsonFormatStrings.IpV6;

            var token = new JValue("test");

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(ValidationErrorKind.IpV6Expected, errors.First().Kind);
        }
开发者ID:tomstreet,项目名称:NJsonSchema,代码行数:15,代码来源:FormatIpV6Tests.cs

示例10: When_format_ipv6_correct_then_validation_succeeds

        public void When_format_ipv6_correct_then_validation_succeeds()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.String;
            schema.Format = JsonFormatStrings.IpV6;

            var token = new JValue("::1");

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(0, errors.Count());
        }
开发者ID:tomstreet,项目名称:NJsonSchema,代码行数:15,代码来源:FormatIpV6Tests.cs

示例11: When_format_guid_correct_then_validation_succeeds

        public void When_format_guid_correct_then_validation_succeeds()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.String;
            schema.Format = JsonFormatStrings.Guid;

            var guid = Guid.NewGuid().ToString();
            var token = new JValue(guid);

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(0, errors.Count());
        }
开发者ID:tomstreet,项目名称:NJsonSchema,代码行数:16,代码来源:FormatGuidTests.cs

示例12: Numeric_type_should_not_trigger_validation_if_has_byte_format

        public void Numeric_type_should_not_trigger_validation_if_has_byte_format()
        {
            //// Arrange
            var numericSchema = new JsonSchema4
                                {
                                    Type = JsonObjectType.Integer,
                                    Format = JsonFormatStrings.Byte
                                };

            var token = new JValue(1);

            //// Act
            var numericErrors = numericSchema.Validate(token);

            //// Assert
            Assert.AreEqual(0, numericErrors.Count);
        }
开发者ID:tomstreet,项目名称:NJsonSchema,代码行数:17,代码来源:FormatBase64Tests.cs

示例13: GetEnumeration

        private List<EnumerationEntry> GetEnumeration(JsonSchema4 schema)
        {
            var entries = new List<EnumerationEntry>();
            for (int i = 0; i < schema.Enumeration.Count; i++)
            {
                var value = schema.Enumeration.ElementAt(i);
                var name = schema.EnumerationNames.Count > i ?
                    schema.EnumerationNames.ElementAt(i) :
                    schema.Type == JsonObjectType.Integer ? "_" + value : value.ToString();

                entries.Add(new EnumerationEntry
                {
                    Value = schema.Type == JsonObjectType.Integer ? value.ToString() : "<any>\"" + value + "\"",
                    Name = ConversionUtilities.ConvertToUpperCamelCase(name, true)
                });
            }
            return entries;
        }
开发者ID:tomstreet,项目名称:NJsonSchema,代码行数:18,代码来源:EnumTemplateModel.cs

示例14: When_optional_property_is_missing_then_it_should_succeed

        public void When_optional_property_is_missing_then_it_should_succeed()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.Object;
            schema.Properties["Foo"] = new JsonProperty
            {
                IsRequired = false,
            };

            var token = new JObject();

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(0, errors.Count());
        }
开发者ID:vmaramreddy1,项目名称:NJsonSchema,代码行数:18,代码来源:ObjectValidationTests.cs

示例15: When_array_item_are_valid_then_it_should_succeed

        public void When_array_item_are_valid_then_it_should_succeed()
        {
            //// Arrange
            var schema = new JsonSchema4();
            schema.Type = JsonObjectType.Array;
            schema.Item = new JsonSchema4();
            schema.Item.Type = JsonObjectType.String;

            var token = new JArray();
            token.Add(new JValue("Foo"));
            token.Add(new JValue("Bar"));

            //// Act
            var errors = schema.Validate(token);

            //// Assert
            Assert.AreEqual(0, errors.Count());
        }
开发者ID:vmaramreddy1,项目名称:NJsonSchema,代码行数:18,代码来源:ArrayValidationTests.cs


注:本文中的JsonSchema4类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。