示例#1
0
        public void ValidationSchema_Validate_Partial_Error()
        {
            var actual = new ObservationDatasetResultSchema(new SchemaField[] {
                new SchemaField {
                    Name = "personId", Type = LeafType.String
                },
                new SchemaField {
                    Name = "effectiveDate", Type = LeafType.DateTime
                },
                new SchemaField {
                    Name = "encounterId", Type = LeafType.String
                },
                new SchemaField {
                    Name = "specimenType", Type = LeafType.String
                },
                new SchemaField {
                    Name = "valueString", Type = LeafType.String
                },
                new SchemaField {
                    Name = "valueQuantity", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "valueUnit", Type = LeafType.String
                },
            });
            var schema = ObservationValidationSchema.Schema;

            var result = schema.Validate(actual);

            Assert.Equal(SchemaValidationState.Error, result.State);
        }
示例#2
0
        public void ShapedDatasetSchema_Should_Prune_Salt()
        {
            var actual = new ObservationDatasetResultSchema(new SchemaField[] {
                new SchemaField {
                    Name = "personId", Type = LeafType.String
                },
                new SchemaField {
                    Name = "category", Type = LeafType.String
                },
                new SchemaField {
                    Name = "code", Type = LeafType.String
                },
                new SchemaField {
                    Name = "effectiveDate", Type = LeafType.DateTime
                },
                new SchemaField {
                    Name = "encounterId", Type = LeafType.String
                },
                new SchemaField {
                    Name = "referenceRangeLow", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "referenceRangeHigh", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "specimenType", Type = LeafType.String
                },
                new SchemaField {
                    Name = "valueString", Type = LeafType.String
                },
                new SchemaField {
                    Name = "valueQuantity", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "valueUnit", Type = LeafType.String
                },
                new SchemaField {
                    Name = "unrecognizedField", Type = LeafType.String
                },
                new SchemaField {
                    Name = "Salt", Type = LeafType.Guid
                }
            });

            var datasetSchema = ShapedDatasetSchema.From(actual);

            Assert.DoesNotContain(datasetSchema.Fields, f => f.Name == "Salt");
            Assert.DoesNotContain(datasetSchema.Fields, f => f.Name == "unrecognizedField");
        }
示例#3
0
        public void ValidationSchema_Validate_Overflow_Warning()
        {
            var actual = new ObservationDatasetResultSchema(new SchemaField[] {
                new SchemaField {
                    Name = "personId", Type = LeafType.String
                },
                new SchemaField {
                    Name = "category", Type = LeafType.String
                },
                new SchemaField {
                    Name = "code", Type = LeafType.String
                },
                new SchemaField {
                    Name = "effectiveDate", Type = LeafType.DateTime
                },
                new SchemaField {
                    Name = "encounterId", Type = LeafType.String
                },
                new SchemaField {
                    Name = "referenceRangeLow", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "referenceRangeHigh", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "specimenType", Type = LeafType.String
                },
                new SchemaField {
                    Name = "valueString", Type = LeafType.String
                },
                new SchemaField {
                    Name = "valueQuantity", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "valueUnit", Type = LeafType.String
                },
                new SchemaField {
                    Name = "unrecognizedField", Type = LeafType.String
                },
            });
            var schema = ObservationValidationSchema.Schema;

            var result = schema.CheckOverflow(actual);

            Assert.Equal(SchemaValidationState.Warning, result.State);
        }
示例#4
0
        public void ValidationSchema_Shapes_Overflowed_Schema_Ok()
        {
            var actual = new ObservationDatasetResultSchema(new SchemaField[] {
                new SchemaField {
                    Name = "personId", Type = LeafType.String
                },
                new SchemaField {
                    Name = "category", Type = LeafType.String
                },
                new SchemaField {
                    Name = "code", Type = LeafType.String
                },
                new SchemaField {
                    Name = "effectiveDate", Type = LeafType.DateTime
                },
                new SchemaField {
                    Name = "encounterId", Type = LeafType.String
                },
                new SchemaField {
                    Name = "referenceRangeLow", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "referenceRangeHigh", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "specimenType", Type = LeafType.String
                },
                new SchemaField {
                    Name = "valueString", Type = LeafType.String
                },
                new SchemaField {
                    Name = "valueQuantity", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "valueUnit", Type = LeafType.String
                },
                new SchemaField {
                    Name = "testCol", Type = LeafType.String
                },
            });
            var schema = ObservationValidationSchema.Schema;

            var final = schema.GetShapedSchema(actual);

            Assert.DoesNotContain(final.Fields, f => f.Name == "testCol");
        }
示例#5
0
        public void ValidationSchema_Validate_Exact_Ok()
        {
            var actual = new ObservationDatasetResultSchema(new SchemaField[] {
                new SchemaField {
                    Name = "personId", Type = LeafType.String
                },
                new SchemaField {
                    Name = "category", Type = LeafType.String
                },
                new SchemaField {
                    Name = "code", Type = LeafType.String
                },
                new SchemaField {
                    Name = "effectiveDate", Type = LeafType.DateTime
                },
                new SchemaField {
                    Name = "encounterId", Type = LeafType.String
                },
                new SchemaField {
                    Name = "referenceRangeLow", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "referenceRangeHigh", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "specimenType", Type = LeafType.String
                },
                new SchemaField {
                    Name = "valueString", Type = LeafType.String
                },
                new SchemaField {
                    Name = "valueQuantity", Type = LeafType.Numeric
                },
                new SchemaField {
                    Name = "valueUnit", Type = LeafType.String
                },
                new SchemaField {
                    Name = "Salt", Type = LeafType.Guid
                },
            });
            var schema = ObservationValidationSchema.Schema;

            var result = schema.Validate(actual);

            Assert.Equal(SchemaValidationState.Ok, result.State);
        }