public void Can_get_and_set_IsNull()
        {
            var conditionPropertyMapping
                = new IsNullConditionMapping(new EdmProperty("C", TypeUsage.Create(new PrimitiveType { DataSpace = DataSpace.SSpace })), false);

            Assert.Null(conditionPropertyMapping.Value);
            Assert.False((bool)conditionPropertyMapping.IsNull);
        }
Exemplo n.º 2
0
        public void Can_get_and_set_IsNull()
        {
            var conditionPropertyMapping
                = new IsNullConditionMapping(new EdmProperty("C", TypeUsage.Create(new PrimitiveType {
                DataSpace = DataSpace.SSpace
            })), false);

            Assert.Null(conditionPropertyMapping.Value);
            Assert.False((bool)conditionPropertyMapping.IsNull);
        }
Exemplo n.º 3
0
        public void Cannot_add_condition_when_read_only()
        {
            var complexType        = new ComplexType();
            var complexTypeMapping = new ComplexTypeMapping(complexType);

            complexTypeMapping.SetReadOnly();

            var conditionMapping = new IsNullConditionMapping(new EdmProperty("P"), true);

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws <InvalidOperationException>(
                    () => complexTypeMapping.AddCondition(conditionMapping)).Message);
        }
Exemplo n.º 4
0
        public void Can_create_is_null_condition_mapping_with_column()
        {
            var primitiveType = FakeSqlProviderServices.Instance.GetProviderManifest("2008").GetStoreTypes().First();
            var column        = EdmProperty.CreatePrimitive("C", primitiveType);
            var mapping1      = new IsNullConditionMapping(column, true);
            var mapping2      = new IsNullConditionMapping(column, false);

            Assert.Same(column, mapping1.Column);
            Assert.Same(column, mapping2.Column);
            Assert.Null(mapping1.Property);
            Assert.Null(mapping2.Property);
            Assert.Equal(true, mapping1.IsNull);
            Assert.Equal(false, mapping2.IsNull);
            Assert.Null(mapping1.Value);
            Assert.Null(mapping2.Value);
        }
Exemplo n.º 5
0
        public void Can_create_is_null_condition_mapping_with_property()
        {
            var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String);
            var property      = EdmProperty.CreatePrimitive("P", primitiveType);
            var mapping1      = new IsNullConditionMapping(property, true);
            var mapping2      = new IsNullConditionMapping(property, false);

            Assert.Same(property, mapping1.Property);
            Assert.Same(property, mapping2.Property);
            Assert.Null(mapping1.Column);
            Assert.Null(mapping2.Column);
            Assert.Equal(true, mapping1.IsNull);
            Assert.Equal(false, mapping2.IsNull);
            Assert.Null(mapping1.Value);
            Assert.Null(mapping2.Value);
        }
        public void Can_create_is_null_condition_mapping_with_column()
        {
            var primitiveType = FakeSqlProviderServices.Instance.GetProviderManifest("2008").GetStoreTypes().First();
            var column = EdmProperty.CreatePrimitive("C", primitiveType);
            var mapping1 = new IsNullConditionMapping(column, true);
            var mapping2 = new IsNullConditionMapping(column, false);

            Assert.Same(column, mapping1.Column);
            Assert.Same(column, mapping2.Column);
            Assert.Null(mapping1.Property);
            Assert.Null(mapping2.Property);
            Assert.Equal(true, mapping1.IsNull);
            Assert.Equal(false, mapping2.IsNull);
            Assert.Null(mapping1.Value);
            Assert.Null(mapping2.Value);
        }
        public void Can_create_is_null_condition_mapping_with_property()
        {
            var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String);
            var property = EdmProperty.CreatePrimitive("P", primitiveType);
            var mapping1 = new IsNullConditionMapping(property, true);
            var mapping2 = new IsNullConditionMapping(property, false);

            Assert.Same(property, mapping1.Property);
            Assert.Same(property, mapping2.Property);
            Assert.Null(mapping1.Column);
            Assert.Null(mapping2.Column);
            Assert.Equal(true, mapping1.IsNull);
            Assert.Equal(false, mapping2.IsNull);
            Assert.Null(mapping1.Value);
            Assert.Null(mapping2.Value);
        }
        public void Can_add_remove_conditions()
        {
            var complexType = new ComplexType();
            var complexTypeMapping = new ComplexTypeMapping(complexType);
            var conditionMapping = new IsNullConditionMapping(new EdmProperty("P"), true);

            Assert.Empty(complexTypeMapping.Conditions);

            complexTypeMapping.AddCondition(conditionMapping);

            Assert.Same(conditionMapping, complexTypeMapping.Conditions.Single());

            complexTypeMapping.RemoveCondition(conditionMapping);

            Assert.Empty(complexTypeMapping.Conditions);
        }
Exemplo n.º 9
0
        public void Can_add_remove_conditions()
        {
            var complexType        = new ComplexType();
            var complexTypeMapping = new ComplexTypeMapping(complexType);
            var conditionMapping   = new IsNullConditionMapping(new EdmProperty("P"), true);

            Assert.Empty(complexTypeMapping.Conditions);

            complexTypeMapping.AddCondition(conditionMapping);

            Assert.Same(conditionMapping, complexTypeMapping.Conditions.Single());

            complexTypeMapping.RemoveCondition(conditionMapping);

            Assert.Empty(complexTypeMapping.Conditions);
        }
Exemplo n.º 10
0
        public void Cannot_add_condition_when_read_only()
        {
            var mappingFragment
                = new MappingFragment(
                      new EntitySet(),
                      new EntityTypeMapping(
                          new EntitySetMapping(
                              new EntitySet(),
                              new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false);

            mappingFragment.SetReadOnly();

            var conditionMapping = new IsNullConditionMapping(new EdmProperty("P"), true);

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws <InvalidOperationException>(
                    () => mappingFragment.AddCondition(conditionMapping)).Message);
        }
Exemplo n.º 11
0
        public void SetReadOnly_is_called_on_child_mapping_items()
        {
            var complexType           = new ComplexType();
            var complexTypeMapping    = new ComplexTypeMapping(complexType);
            var scalarPropertyMapping = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType()
            {
                DataSpace = DataSpace.SSpace
            })));
            var conditionMapping = new IsNullConditionMapping(new EdmProperty("P"), true);

            complexTypeMapping.AddProperty(scalarPropertyMapping);
            complexTypeMapping.AddCondition(conditionMapping);

            Assert.False(scalarPropertyMapping.IsReadOnly);
            Assert.False(conditionMapping.IsReadOnly);
            complexTypeMapping.SetReadOnly();
            Assert.True(scalarPropertyMapping.IsReadOnly);
            Assert.True(conditionMapping.IsReadOnly);
        }
Exemplo n.º 12
0
        public void SetReadOnly_is_called_on_child_mapping_items()
        {
            var mappingFragment
                = new MappingFragment(
                      new EntitySet(),
                      new EntityTypeMapping(
                          new EntitySetMapping(
                              new EntitySet(),
                              new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false);
            var scalarPropertyMapping = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType()
            {
                DataSpace = DataSpace.SSpace
            })));
            var conditionMapping = new IsNullConditionMapping(new EdmProperty("P"), true);

            mappingFragment.AddPropertyMapping(scalarPropertyMapping);
            mappingFragment.AddCondition(conditionMapping);

            Assert.False(scalarPropertyMapping.IsReadOnly);
            Assert.False(conditionMapping.IsReadOnly);
            mappingFragment.SetReadOnly();
            Assert.True(scalarPropertyMapping.IsReadOnly);
            Assert.True(conditionMapping.IsReadOnly);
        }
Exemplo n.º 13
0
        public void SetReadOnly_is_called_on_child_mapping_items()
        {
            var mappingFragment
                = new MappingFragment(
                    new EntitySet(),
                    new EntityTypeMapping(
                        new EntitySetMapping(
                            new EntitySet(),
                            new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false);
            var scalarPropertyMapping = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })));
            var conditionMapping = new IsNullConditionMapping(new EdmProperty("P"), true);

            mappingFragment.AddPropertyMapping(scalarPropertyMapping);
            mappingFragment.AddCondition(conditionMapping);

            Assert.False(scalarPropertyMapping.IsReadOnly);
            Assert.False(conditionMapping.IsReadOnly);
            mappingFragment.SetReadOnly();
            Assert.True(scalarPropertyMapping.IsReadOnly);
            Assert.True(conditionMapping.IsReadOnly);
        }
Exemplo n.º 14
0
        public void Cannot_remove_condition_when_read_only()
        {
            var mappingFragment
                = new MappingFragment(
                    new EntitySet(),
                    new EntityTypeMapping(
                        new EntitySetMapping(
                            new EntitySet(),
                            new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false);
            var conditionMapping = new IsNullConditionMapping(new EdmProperty("P"), true);

            mappingFragment.AddCondition(conditionMapping);

            mappingFragment.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws<InvalidOperationException>(
                    () => mappingFragment.RemoveCondition(conditionMapping)).Message);
        }
        public void Cannot_add_condition_when_read_only()
        {
            var complexType = new ComplexType();
            var complexTypeMapping = new ComplexTypeMapping(complexType);

            complexTypeMapping.SetReadOnly();

            var conditionMapping = new IsNullConditionMapping(new EdmProperty("P"), true);

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws<InvalidOperationException>(
                    () => complexTypeMapping.AddCondition(conditionMapping)).Message);
        }
        public void SetReadOnly_is_called_on_child_mapping_items()
        {
            var complexType = new ComplexType();
            var complexTypeMapping = new ComplexTypeMapping(complexType);
            var scalarPropertyMapping = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })));
            var conditionMapping = new IsNullConditionMapping(new EdmProperty("P"), true);

            complexTypeMapping.AddPropertyMapping(scalarPropertyMapping);
            complexTypeMapping.AddCondition(conditionMapping);

            Assert.False(scalarPropertyMapping.IsReadOnly);
            Assert.False(conditionMapping.IsReadOnly);
            complexTypeMapping.SetReadOnly();
            Assert.True(scalarPropertyMapping.IsReadOnly);
            Assert.True(conditionMapping.IsReadOnly);
        }