public void Can_SetActionTitle_OnBindable_Actions() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); EntitySetConfiguration <Movie> movies = builder.EntitySet <Movie>("Movies"); movies.EntityType.HasKey(m => m.ID); ActionConfiguration entityAction = movies.EntityType.Action("Checkout"); entityAction.Returns <int>(); entityAction.Title = "Check out"; ActionConfiguration collectionAction = movies.EntityType.Collection.Action("RemoveOld"); collectionAction.Returns <int>(); collectionAction.Title = "Remove Old Movies"; // Act IEdmModel model = builder.GetEdmModel(); IEdmOperation checkout = model.FindOperations("Default.Checkout").Single(); IEdmOperation removeOld = model.FindOperations("Default.RemoveOld").Single(); OperationTitleAnnotation checkoutTitle = model.GetOperationTitleAnnotation(checkout); OperationTitleAnnotation removeOldTitle = model.GetOperationTitleAnnotation(removeOld); // Assert Assert.NotNull(checkoutTitle); Assert.Equal("Check out", checkoutTitle.Title); Assert.NotNull(removeOldTitle); Assert.Equal("Remove Old Movies", removeOldTitle.Title); }
public void CanCreateActionWithPrimitiveReturnType() { // Arrange // Act ODataModelBuilder builder = new ODataModelBuilder(); ActionConfiguration action = builder.Action("CreateMessage"); action.Returns <string>(); // Assert Assert.NotNull(action.ReturnType); Assert.Equal("Edm.String", action.ReturnType.FullName); }
public void UnboundAction_ForEnumWithShortUnderlyingTypeInODataConventionModelBuilder() { // Arrange ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); ActionConfiguration actionConfiguration = builder.Action("UnboundAction"); actionConfiguration.Returns <ShortEnum>(); // Act & Assert IEdmModel model = builder.GetEdmModel(); IEdmAction action = model.FindDeclaredOperations("Default.UnboundAction").Single() as IEdmAction; IEdmTypeReference returnType = action.ReturnType; IEdmEnumType shortEnumType = model.SchemaElements.OfType <IEdmEnumType>().Single(e => e.Name == "ShortEnum"); Assert.Same(shortEnumType, returnType.Definition); Assert.Equal(EdmPrimitiveTypeKind.Int16, returnType.AsEnum().EnumDefinition().UnderlyingType.PrimitiveKind); }
public void Cant_SetActionTile_OnNonBindableActions() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); ActionConfiguration action = builder.Action("MyAction"); action.Returns <int>(); action.Title = "My Action"; // Act IEdmModel model = builder.GetEdmModel(); IEdmOperationImport actionImport = model.EntityContainer.OperationImports().OfType <IEdmActionImport>().Single(); Assert.NotNull(actionImport); OperationTitleAnnotation actionTitleAnnotation = model.GetOperationTitleAnnotation(actionImport.Operation); // Assert Assert.Null(actionTitleAnnotation); }
public void UnboundAction_ForEnumTypeInODataModelBuilder() { // Arrange ODataModelBuilder builder = new ODataModelBuilder().Add_Color_EnumType(); ActionConfiguration actionConfiguration = builder.Action("UnboundAction"); actionConfiguration.Parameter <Color>("Color"); actionConfiguration.Returns <Color>(); // Act & Assert IEdmModel model = builder.GetEdmModel(); IEdmActionImport actionImport = model.EntityContainer.OperationImports().Single(o => o.Name == "UnboundAction") as IEdmActionImport; IEdmTypeReference color = actionImport.Action.Parameters.Single(p => p.Name == "Color").Type; IEdmTypeReference returnType = actionImport.Action.ReturnType; IEdmEnumType colorType = model.SchemaElements.OfType <IEdmEnumType>().Single(e => e.Name == "Color"); Assert.False(color.IsNullable); Assert.Same(colorType, color.Definition); Assert.False(returnType.IsNullable); Assert.Same(colorType, returnType.Definition); }