예제 #1
0
        public void Can_remove_annotation_by_setting_null()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value      = new object();

            entityType.AddAnnotation("name", value);

            Assert.NotEmpty(entityType.Annotations);

            entityType.AddAnnotation("name", null);

            Assert.Empty(entityType.Annotations);
        }
예제 #2
0
        public void Can_remove_annotation_by_setting_null()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value = new object();

            entityType.AddAnnotation("name", value);

            Assert.NotEmpty(entityType.Annotations);

            entityType.AddAnnotation("name", null);

            Assert.Empty(entityType.Annotations);
        }
예제 #3
0
        public void AddAnnotation_checks_arguments()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            Assert.Equal(
                Strings.ArgumentIsNullOrWhitespace("name"),
                Assert.Throws<ArgumentException>(() => entityType.AddAnnotation(null, null)).Message);

            Assert.Equal(
                Strings.ArgumentIsNullOrWhitespace("name"),
                Assert.Throws<ArgumentException>(() => entityType.AddAnnotation("", null)).Message);

            Assert.Equal(
                Strings.ArgumentIsNullOrWhitespace("name"),
                Assert.Throws<ArgumentException>(() => entityType.AddAnnotation(" ", null)).Message);
        }
예제 #4
0
        public void AddAnnotation_checks_arguments()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            Assert.Equal(
                Strings.ArgumentIsNullOrWhitespace("name"),
                Assert.Throws <ArgumentException>(() => entityType.AddAnnotation(null, null)).Message);

            Assert.Equal(
                Strings.ArgumentIsNullOrWhitespace("name"),
                Assert.Throws <ArgumentException>(() => entityType.AddAnnotation("", null)).Message);

            Assert.Equal(
                Strings.ArgumentIsNullOrWhitespace("name"),
                Assert.Throws <ArgumentException>(() => entityType.AddAnnotation(" ", null)).Message);
        }
예제 #5
0
        public void Passing_a_null_value_causes_annotation_to_not_be_set()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            entityType.AddAnnotation("name", null);

            Assert.Empty(entityType.Annotations);
        }
예제 #6
0
        public void Passing_a_null_value_causes_annotation_to_not_be_set()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            entityType.AddAnnotation("name", null);

            Assert.Empty(entityType.Annotations);
        }
예제 #7
0
        public void RemoveAnnotation_returns_false_if_annotation_not_found()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value      = new object();

            entityType.AddAnnotation("name", value);

            Assert.False(entityType.RemoveAnnotation("notfound"));
        }
예제 #8
0
        public void AddAnnotation_throws_if_metadata_item_is_readonly()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value      = new object();

            entityType.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyCollection,
                Assert.Throws <InvalidOperationException>(() => entityType.AddAnnotation("name", value))
                .Message);
        }
예제 #9
0
        public void Can_remove_annotation()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value = new object();

            entityType.AddAnnotation("name", value);
            
            Assert.NotEmpty(entityType.Annotations);

            Assert.True(entityType.RemoveAnnotation("name"));

            Assert.Empty(entityType.Annotations);
        }
예제 #10
0
        public void Can_remove_annotation()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value      = new object();

            entityType.AddAnnotation("name", value);

            Assert.NotEmpty(entityType.Annotations);

            Assert.True(entityType.RemoveAnnotation("name"));

            Assert.Empty(entityType.Annotations);
        }
예제 #11
0
        public void Setting_annotation_value_throws_if_metadata_item_is_readonly()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value1     = new object();
            var value2     = new object();

            entityType.AddAnnotation("name", value1);
            entityType.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws <InvalidOperationException>(() => entityType.Annotations.Single().Value = value2)
                .Message);
        }
        public void Setting_annotation_value_throws_if_metadata_item_is_readonly()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value1 = new object();
            var value2 = new object();

            entityType.AddAnnotation("name", value1);
            entityType.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws<InvalidOperationException>(() => entityType.Annotations.Single().Value = value2)
                    .Message);
        }
예제 #13
0
        public void Can_add_and_get_annotation()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value = new object();

            Assert.Empty(entityType.Annotations);

            entityType.AddAnnotation("name", value);

            Assert.NotEmpty(entityType.Annotations);
            Assert.Equal(1, entityType.Annotations.Count());

            var annotation = entityType.Annotations.Single();

            Assert.Equal("name", annotation.Name);
            Assert.Same(value, annotation.Value);
        }
예제 #14
0
        public void Can_add_and_get_annotation()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value      = new object();

            Assert.Empty(entityType.Annotations);

            entityType.AddAnnotation("name", value);

            Assert.NotEmpty(entityType.Annotations);
            Assert.Equal(1, entityType.Annotations.Count);

            var annotation = entityType.Annotations.Single();

            Assert.Equal("name", annotation.Name);
            Assert.Same(value, annotation.Value);
        }
예제 #15
0
        public void RemoveAnnotation_returns_false_if_annotation_not_found()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value = new object();

            entityType.AddAnnotation("name", value);

            Assert.False(entityType.RemoveAnnotation("notfound"));
        }
예제 #16
0
        public void GetAnnotations_returns_only_annotations_with_annotation_prefix_and_strips_prefix()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            Assert.Empty(EdmModelDiffer.GetAnnotations(entityType));

            entityType.AddAnnotation("name", new object());

            Assert.Empty(EdmModelDiffer.GetAnnotations(entityType));

            entityType.AddAnnotation(XmlConstants.CustomAnnotationPrefix + "First", "Amy");
            entityType.AddAnnotation(XmlConstants.CustomAnnotationPrefix + "Last", "Winehouse");

            Assert.Equal(2, EdmModelDiffer.GetAnnotations(entityType).Count);
            Assert.Same("Amy", EdmModelDiffer.GetAnnotations(entityType)["First"]);
            Assert.Same("Winehouse", EdmModelDiffer.GetAnnotations(entityType)["Last"]);

            entityType.AddAnnotation(XmlConstants.IndexAnnotationWithPrefix, new IndexAnnotation(new IndexAttribute()));

            Assert.Equal(2, EdmModelDiffer.GetAnnotations(entityType).Count);
        }
예제 #17
0
        public void AddAnnotation_throws_if_metadata_item_is_readonly()
        {
            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            var value = new object();

            entityType.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyCollection,
                Assert.Throws<InvalidOperationException>(() => entityType.AddAnnotation("name", value))
                    .Message);
        }