public void BoundAction_ForEnumTypeInODataModelBuilder() { // Arrange ODataModelBuilder builder = ODataModelBuilderMocks.GetModelBuilderMock <ODataModelBuilder>(); EntityTypeConfiguration <EnumModel> entityTypeConfiguration = builder.EntityType <EnumModel>(); ActionConfiguration actionConfiguration = entityTypeConfiguration.Action("BoundAction"); actionConfiguration.CollectionParameter <Color>("Colors"); actionConfiguration.ReturnsCollection <Color?>(); builder.Add_Color_EnumType(); // Act & Assert IEdmModel model = builder.GetEdmModel(); IEdmAction action = model.FindDeclaredOperations("Default.BoundAction").Single() as IEdmAction; IEdmTypeReference colors = action.Parameters.Single(p => p.Name == "Colors").Type; IEdmTypeReference returnType = action.ReturnType; IEdmEnumType colorType = model.SchemaElements.OfType <IEdmEnumType>().Single(e => e.Name == "Color"); Assert.True(colors.IsCollection()); Assert.Same(colorType, colors.AsCollection().ElementType().Definition); Assert.True(returnType.IsCollection()); Assert.True(returnType.AsCollection().ElementType().IsNullable); Assert.Same(colorType, returnType.AsCollection().ElementType().Definition); }
public void UnboundFunction_ForEnumTypeInODataModelBuilder() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); FunctionConfiguration functionConfiguration = builder.Function("UnboundFunction"); functionConfiguration.CollectionParameter <Color>("Colors"); functionConfiguration.ReturnsCollection <Color>(); builder.Add_Color_EnumType(); // Act & Assert IEdmModel model = builder.GetEdmModel(); IEdmFunctionImport functionImport = model.EntityContainer.OperationImports().Single(o => o.Name == "UnboundFunction") as IEdmFunctionImport; IEdmTypeReference colors = functionImport.Function.Parameters.Single(p => p.Name == "Colors").Type; IEdmTypeReference returnType = functionImport.Function.ReturnType; IEdmEnumType colorType = model.SchemaElements.OfType <IEdmEnumType>().Single(e => e.Name == "Color"); Assert.True(colors.IsCollection()); Assert.Same(colorType, colors.AsCollection().ElementType().Definition); Assert.True(returnType.IsCollection()); Assert.False(returnType.AsCollection().ElementType().IsNullable); Assert.Same(colorType, returnType.AsCollection().ElementType().Definition); }