public void FindEntailsSchemaAnnotationInstanceBuildingForEachSchema()
        {
            SchemaAnnotationCollection.Create(SchemaMetadata.For <Envelope>()).Find <AnnotationDummy>().Should().NotBeNull();
            AnnotationDummy.AnnotationDummySpy
            .Verify(ads => ads.Build(It.IsAny <ISchemaAnnotationReader>()), Times.Once);

            SchemaAnnotationCollection.Create(SchemaMetadata.For <Any>()).Find <AnnotationDummy>().Should().NotBeNull();
            AnnotationDummy.AnnotationDummySpy
            .Verify(ads => ads.Build(It.IsAny <ISchemaAnnotationReader>()), Times.Once);

            SchemaAnnotationCollection.Create(SchemaMetadata.For <BTS.soap_envelope_1__2.Fault>()).Find <AnnotationDummy>().Should().NotBeNull();
            AnnotationDummy.AnnotationDummySpy
            .Verify(ads => ads.Build(It.IsAny <ISchemaAnnotationReader>()), Times.Once);
        }
Exemple #2
0
            internal RootlessSchemaMetadata(Type type)
            {
                Type = type ?? throw new ArgumentNullException(nameof(type));
                if (!type.IsDocumentSchema())
                {
                    throw new ArgumentException(
                              $"{nameof(SchemaMetadata)} only supports schemas qualified with a {nameof(SchemaTypeAttribute)} whose {nameof(SchemaTypeAttribute.Type)} is equal to {nameof(SchemaTypeEnum.Document)}.",
                              nameof(type));
                }

                var schemaBase = (SchemaBase)Activator.CreateInstance(type);

                TargetNamespace = schemaBase.Schema.TargetNamespace;
                _annotations    = new Lazy <ISchemaAnnotationCollection>(() => SchemaAnnotationCollection.Create(this));
            }
        public void FindEntailsSingleSchemaAnnotationInstanceBuildingForOneSchema()
        {
            // notice we create and reuse SchemaAnnotationCollection similarly to what SchemaMetadata does
            var schemaAnnotationCollection = SchemaAnnotationCollection.Create(SchemaMetadata.For <Envelope>());

            var annotationDummy = schemaAnnotationCollection.Find <AnnotationDummy>();

            annotationDummy.Should().NotBeNull();

            AnnotationDummy.AnnotationDummySpy
            .Verify(ads => ads.Build(It.IsAny <ISchemaAnnotationReader>()), Times.Once);
            AnnotationDummy.AnnotationDummySpy.Invocations.Clear();

            // build is not called anymore and same SchemaAnnotation instance is returned
            schemaAnnotationCollection.Find <AnnotationDummy>().Should().BeSameAs(annotationDummy);
            AnnotationDummy.AnnotationDummySpy
            .Verify(ads => ads.Build(It.IsAny <ISchemaAnnotationReader>()), Times.Never);
        }
Exemple #4
0
 internal RootedSchemaMetadata(Type type)
 {
     Type         = type ?? throw new ArgumentNullException(nameof(type));
     _annotations = new Lazy <ISchemaAnnotationCollection>(() => SchemaAnnotationCollection.Create(this));
 }
Exemple #5
0
 internal UnknownSchemaMetadata()
 {
     _annotations = new Lazy <ISchemaAnnotationCollection>(() => SchemaAnnotationCollection.Create(this));
 }