Ejemplo n.º 1
0
        public void AnnotatedModelShouldSupportAddingStringAnnotations()
        {
            var primaryModel    = new EdmModel();
            var entityContainer = new EdmEntityContainer("Fake", "Container");

            primaryModel.AddElement(entityContainer);

            var testSubject = new VocabularyAnnotationCache(primaryModel);

            var annotation = new EdmVocabularyAnnotation(entityContainer, new EdmTerm("fake", "foo", EdmPrimitiveTypeKind.String), new EdmStringConstant("bar"));

            testSubject.Add(annotation);
            testSubject.FindDeclaredVocabularyAnnotations(entityContainer).Should().Contain(annotation).And.HaveCount(1);
        }
Ejemplo n.º 2
0
        public void NullAnnotationsModel()
        {
            DataServiceConfiguration    config;
            DataServiceOperationContext operationContext;

            CreateProvider(out config, out operationContext);

            config.AnnotationsBuilder = model => new IEdmModel[] { null };

            var    testSubject        = new VocabularyAnnotationCache(new EdmModel());
            Action populateFromConfig = () => testSubject.PopulateFromConfiguration(config);

            populateFromConfig.ShouldThrow <InvalidOperationException>().WithMessage("The collection returned by DataServiceConfiguration.AnnotationsBuilder must not contain null elements.");
        }
Ejemplo n.º 3
0
        public void NullAnnotationsBuilderResult()
        {
            DataServiceConfiguration    config;
            DataServiceOperationContext operationContext;

            CreateProvider(out config, out operationContext);

            config.AnnotationsBuilder = (model) => null;

            var testSubject = new VocabularyAnnotationCache(new EdmModel());

            testSubject.PopulateFromConfiguration(config);

            testSubject.VocabularyAnnotations.Should().BeEmpty();
        }
Ejemplo n.º 4
0
        public void AnnotatedModelShouldSupportAddingStringAnnotations()
        {
            var primaryModel = new EdmModel();
            var entityContainer = new EdmEntityContainer("Fake", "Container");
            primaryModel.AddElement(entityContainer);

            var testSubject = new VocabularyAnnotationCache(primaryModel);

            var annotation = new EdmAnnotation(entityContainer, new EdmTerm("fake", "foo", EdmPrimitiveTypeKind.String), new EdmStringConstant("bar"));
            testSubject.Add(annotation);
            testSubject.FindDeclaredVocabularyAnnotations(entityContainer).Should().Contain(annotation).And.HaveCount(1);
        }
Ejemplo n.º 5
0
        public void NullAnnotationsModel()
        {
            DataServiceConfiguration config;
            DataServiceOperationContext operationContext;
            CreateProvider(out config, out operationContext);

            config.AnnotationsBuilder = model => new IEdmModel[] { null };

            var testSubject = new VocabularyAnnotationCache(new EdmModel());
            Action populateFromConfig = () => testSubject.PopulateFromConfiguration(config);
            populateFromConfig.ShouldThrow<InvalidOperationException>().WithMessage("The collection returned by DataServiceConfiguration.AnnotationsBuilder must not contain null elements.");
        }
Ejemplo n.º 6
0
        public void NullAnnotationsBuilderResult()
        {
            DataServiceConfiguration config;
            DataServiceOperationContext operationContext;
            CreateProvider(out config, out operationContext);

            config.AnnotationsBuilder = (model) => null;

            var testSubject = new VocabularyAnnotationCache(new EdmModel());
            testSubject.PopulateFromConfiguration(config);

            testSubject.VocabularyAnnotations.Should().BeEmpty();
        }