public void MapEntityType_should_not_bring_in_base_class_by_default() { var model = new EdmModel().Initialize(); var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model)); var mockType = new MockType("Bar").BaseType(new MockType("Foo")); var entityType = typeMapper.MapEntityType(mockType); Assert.NotNull(entityType); Assert.Null(entityType.BaseType); Assert.Equal(1, model.Namespaces.Single().EntityTypes.Count); Assert.Equal(1, model.Containers.Single().EntitySets.Count); Assert.Equal("Bar", model.GetEntitySet(entityType).Name); }
public void GetEntitySet_should_return_entity_set() { var model = new EdmModel().Initialize(); var entityType = model.AddEntityType("Foo"); model.AddEntitySet("FooSet", entityType); var entitySet = model.GetEntitySet(entityType); Assert.NotNull(entitySet); Assert.Same(entityType, entitySet.ElementType); }
private void ConfigureEntitySetName(EdmEntityType entityType, EdmModel model) { Contract.Requires(entityType != null); Contract.Requires(model != null); if ((EntitySetName == null) || (entityType.BaseType != null)) { return; } var entitySet = model.GetEntitySet(entityType); Contract.Assert(entitySet != null); entitySet.Name = model.GetEntitySets().Except(new[] { entitySet }).UniquifyName(EntitySetName); entitySet.SetConfiguration(this); }
public void MapEntityType_should_create_entity_set_and_add_to_model() { var model = new EdmModel().Initialize(); var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model)); var mockType = new MockType("Foo"); var entityType = typeMapper.MapEntityType(mockType); var entitySet = model.GetEntitySet(entityType); Assert.NotNull(entitySet); Assert.Same(entityType, entitySet.ElementType); Assert.Equal("Foo", entitySet.Name); }