public void Can_set_nullable_facet() { var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32); var property = EdmProperty.Primitive("P", primitiveType); Assert.True(property.Nullable); property.Nullable = false; Assert.False(property.Nullable); }
public void Properties_list_should_be_live_on_reread() { var complexType = new ComplexType("C"); Assert.Empty(complexType.Properties); var property = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); complexType.AddMember(property); Assert.Equal(1, complexType.Properties.Count); }
public void IsPrimaryKeyColumn_should_return_true_when_parent_key_members_contains_member() { var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32); var property = EdmProperty.Primitive("P", primitiveType); Assert.False(property.IsPrimaryKeyColumn); new EntityType().AddKeyMember(property); Assert.True(property.IsPrimaryKeyColumn); }
public void Properties_list_should_be_live_on_reread() { var entityType = new EntityType("E", "N", DataSpace.CSpace); Assert.Empty(entityType.Properties); var property = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); entityType.AddMember(property); Assert.Equal(1, entityType.Properties.Count); }
public void IsUnderlyingPrimitiveType_returns_true_when_underlying_primitive_property() { var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32); var property = EdmProperty.Primitive("P", primitiveType); Assert.True(property.IsUnderlyingPrimitiveType); var enumType = new EnumType(); property = EdmProperty.Enum("P", enumType); Assert.True(property.IsUnderlyingPrimitiveType); }
public void Cannot_create_property_of_invalid_type() { var rowType = RowType.Create( new[] { EdmProperty.Primitive("property", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)) }, null); Assert.Equal( Strings.EdmProperty_InvalidPropertyType(rowType.FullName), Assert.Throws <ArgumentException>(() => EdmProperty.Create("invalidProperty", TypeUsage.Create(rowType))).Message); }
public void Can_set_name_and_parent_notified() { var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32); var property = EdmProperty.Primitive("P", primitiveType); var entityTypeMock = new Mock <StructuralType>(); property.ChangeDeclaringTypeWithoutCollectionFixup(entityTypeMock.Object); property.Name = "Foo"; entityTypeMock.Verify(e => e.NotifyItemIdentityChanged(), Times.Once()); }
public void Can_get_list_of_declared_properties() { var rowType = new RowType(); Assert.Empty(rowType.DeclaredProperties); var property = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); rowType.AddMember(property); Assert.Equal(1, rowType.DeclaredProperties.Count); rowType.RemoveMember(property); }
public void Can_remove_member() { var entityType = new EntityType("E", "N", DataSpace.CSpace); Assert.Empty(entityType.Members); var property = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); entityType.AddMember(property); Assert.Equal(1, entityType.Members.Count); entityType.RemoveMember(property); Assert.Empty(entityType.Members); }
public void Can_set_primitive_type_and_new_type_usage_is_create_with_facets() { var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String); var property = EdmProperty.Primitive("P", primitiveType); property.StoreGeneratedPattern = StoreGeneratedPattern.Computed; property.ConcurrencyMode = ConcurrencyMode.Fixed; property.MaxLength = 42; property.PrimitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Binary); Assert.Equal(StoreGeneratedPattern.Computed, property.StoreGeneratedPattern); Assert.Equal(ConcurrencyMode.Fixed, property.ConcurrencyMode); Assert.Equal(42, property.MaxLength); }
public void IsKeyMember_should_return_true_when_part_of_key() { var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32); var property = EdmProperty.Primitive("P", primitiveType); Assert.False(property.IsKeyMember); var entityType = new EntityType("E", "N", DataSpace.CSpace); entityType.AddMember(property); Assert.False(property.IsKeyMember); entityType.AddKeyMember(property); Assert.True(property.IsKeyMember); }
public void Can_set_and_get_to_role() { var toRole = new AssociationEndMember("D", new EntityType("E", "N", DataSpace.CSpace)); var referentialConstraint = new ReferentialConstraint( new AssociationEndMember("P", new EntityType("E", "N", DataSpace.CSpace)), toRole, new[] { EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)) }, new[] { EdmProperty.Primitive("D", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)) }); Assert.Same(toRole, referentialConstraint.ToRole); var toRole2 = new AssociationEndMember("D2", new EntityType("E", "N", DataSpace.CSpace)); referentialConstraint.ToRole = toRole2; Assert.Same(toRole2, referentialConstraint.ToRole); }
public void Can_set_and_get_dependent_end() { var dependentEnd1 = new AssociationEndMember("D", new EntityType()); var referentialConstraint = new ReferentialConstraint( new AssociationEndMember("P", new EntityType()), dependentEnd1, new[] { EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)) }, new[] { EdmProperty.Primitive("D", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32)) }); Assert.Same(dependentEnd1, referentialConstraint.DependentEnd); var dependentEnd2 = new AssociationEndMember("D2", new EntityType()); referentialConstraint.DependentEnd = dependentEnd2; Assert.Same(dependentEnd2, referentialConstraint.DependentEnd); }
public void UnderlyingPrimitiveType_returns_type_when_underlying_primitive_property() { var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32); var property = EdmProperty.Primitive("P", primitiveType); Assert.Same(primitiveType, property.UnderlyingPrimitiveType); var enumType = new EnumType(); property = EdmProperty.Enum("P", enumType); Assert.Same(primitiveType, property.UnderlyingPrimitiveType); var complexType = new ComplexType(); property = EdmProperty.Complex("P", complexType); Assert.Null(property.UnderlyingPrimitiveType); }
public void Identity_uniquified_when_duplicate_name_set() { var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32); var property1 = EdmProperty.Primitive("Foo", primitiveType); var property2 = EdmProperty.Primitive("Bar", primitiveType); var property3 = EdmProperty.Primitive("Boo", primitiveType); var entityType = new EntityType("T", "S", DataSpace.CSpace); entityType.AddMember(property1); entityType.AddMember(property2); entityType.AddMember(property3); property2.Name = "Foo"; property3.Name = "Foo"; Assert.Equal("Foo1", property2.Identity); Assert.Equal("Foo2", property3.Identity); Assert.Equal(3, entityType.Properties.Count); }
public void Can_get_list_of_declared_properties() { var entityType = new EntityType(); Assert.Empty(entityType.DeclaredProperties); var property = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); entityType.AddMember(property); Assert.Equal(1, entityType.DeclaredProperties.Count); entityType.RemoveMember(property); var baseType = new EntityType(); baseType.AddMember(property); entityType.BaseType = baseType; Assert.Empty(entityType.DeclaredProperties); Assert.Equal(1, entityType.Members.Count); }
public void Can_get_and_set_facet_wrappers() { var property = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); property.ConcurrencyMode = ConcurrencyMode.Fixed; property.CollectionKind = CollectionKind.List; Assert.Equal(ConcurrencyMode.Fixed, property.ConcurrencyMode); Assert.Equal(CollectionKind.List, property.CollectionKind); property.MaxLength = 42; Assert.Equal(42, property.MaxLength.Value); property.IsMaxLength = true; Assert.Null(property.MaxLength); Assert.True(property.IsMaxLength); property.IsFixedLength = true; property.IsUnicode = true; Assert.True(property.IsFixedLength.Value); Assert.True(property.IsUnicode.Value); property = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Decimal)); property.Precision = 42; property.Scale = 42; Assert.Equal(42, property.Precision.Value); Assert.Equal(42, property.Scale.Value); property.StoreGeneratedPattern = StoreGeneratedPattern.Identity; Assert.Equal(StoreGeneratedPattern.Identity, property.StoreGeneratedPattern); }
public void Identity_synced_when_member_goes_readonly_and_parent_notified() { var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32); var property1 = EdmProperty.Primitive("Foo", primitiveType); var property2 = EdmProperty.Primitive("Bar", primitiveType); var property3 = EdmProperty.Primitive("Boo", primitiveType); var entityTypeMock = new Mock <EntityType>("T", "S", DataSpace.CSpace) { CallBase = true }; entityTypeMock.Setup(e => e.NotifyItemIdentityChanged()); entityTypeMock.Object.AddMember(property1); entityTypeMock.Object.AddMember(property2); entityTypeMock.Object.AddMember(property3); property2.Name = "Foo"; property3.Name = "Foo"; Assert.Equal("Foo1", property2.Identity); Assert.Equal("Foo2", property3.Identity); entityTypeMock.Verify(e => e.NotifyItemIdentityChanged(), Times.Exactly(2)); property2.SetReadOnly(); Assert.Equal("Foo", property2.Identity); entityTypeMock.Verify(e => e.NotifyItemIdentityChanged(), Times.Exactly(3)); property3.SetReadOnly(); Assert.Equal("Foo", property3.Identity); entityTypeMock.Verify(e => e.NotifyItemIdentityChanged(), Times.Exactly(4)); }