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); }
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."); }
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(); }
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); }
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."); }