public void CanCreateActionWithNonbindingParametersAsNullable() { // Arrange & Act ODataModelBuilder builder = new ODataModelBuilder(); ActionConfiguration action = builder.Action("MyAction"); action.Parameter <string>("p0"); action.Parameter <string>("p1").OptionalParameter = false; action.Parameter <int>("p2").OptionalParameter = true; action.Parameter <int>("p3"); action.Parameter <Address>("p4"); action.Parameter <Address>("p5").OptionalParameter = false; action.CollectionParameter <ZipCode>("p6"); action.CollectionParameter <ZipCode>("p7").OptionalParameter = false; action.EntityParameter <Customer>("p8"); action.EntityParameter <Customer>("p9").OptionalParameter = false; action.CollectionEntityParameter <Customer>("p10"); action.CollectionEntityParameter <Customer>("p11").OptionalParameter = false; Dictionary <string, ParameterConfiguration> parameters = action.Parameters.ToDictionary(e => e.Name, e => e); // Assert Assert.True(parameters["p0"].OptionalParameter); Assert.False(parameters["p1"].OptionalParameter); Assert.True(parameters["p2"].OptionalParameter); Assert.False(parameters["p3"].OptionalParameter); Assert.True(parameters["p4"].OptionalParameter); Assert.False(parameters["p5"].OptionalParameter); Assert.True(parameters["p6"].OptionalParameter); Assert.False(parameters["p7"].OptionalParameter); Assert.True(parameters["p8"].OptionalParameter); Assert.False(parameters["p9"].OptionalParameter); Assert.True(parameters["p10"].OptionalParameter); Assert.False(parameters["p11"].OptionalParameter); }
public void CanCreateActionWithNonbindingParameters() { // Arrange // Act ODataModelBuilder builder = new ODataModelBuilder(); ActionConfiguration action = builder.Action("MyAction"); action.Parameter <string>("p0"); action.Parameter <int>("p1"); action.Parameter <Address>("p2"); action.CollectionParameter <string>("p3"); action.CollectionParameter <int>("p4"); action.CollectionParameter <ZipCode>("p5"); action.EntityParameter <Customer>("p6"); action.CollectionEntityParameter <Employee>("p7"); ParameterConfiguration[] parameters = action.Parameters.ToArray(); ComplexTypeConfiguration[] complexTypes = builder.StructuralTypes.OfType <ComplexTypeConfiguration>().ToArray(); EntityTypeConfiguration[] entityTypes = builder.StructuralTypes.OfType <EntityTypeConfiguration>().ToArray(); // Assert Assert.Equal(2, complexTypes.Length); Assert.Equal(typeof(Address).FullName, complexTypes[0].FullName); Assert.Equal(typeof(ZipCode).FullName, complexTypes[1].FullName); Assert.Equal(2, entityTypes.Length); Assert.Equal(typeof(Customer).FullName, entityTypes[0].FullName); Assert.Equal(typeof(Employee).FullName, entityTypes[1].FullName); Assert.Equal(8, parameters.Length); Assert.Equal("p0", parameters[0].Name); Assert.Equal("Edm.String", parameters[0].TypeConfiguration.FullName); Assert.Equal("p1", parameters[1].Name); Assert.Equal("Edm.Int32", parameters[1].TypeConfiguration.FullName); Assert.Equal("p2", parameters[2].Name); Assert.Equal(typeof(Address).FullName, parameters[2].TypeConfiguration.FullName); Assert.Equal("p3", parameters[3].Name); Assert.Equal("Collection(Edm.String)", parameters[3].TypeConfiguration.FullName); Assert.Equal("p4", parameters[4].Name); Assert.Equal("Collection(Edm.Int32)", parameters[4].TypeConfiguration.FullName); Assert.Equal("p5", parameters[5].Name); Assert.Equal(string.Format("Collection({0})", typeof(ZipCode).FullName), parameters[5].TypeConfiguration.FullName); Assert.Equal("p6", parameters[6].Name); Assert.Equal(typeof(Customer).FullName, parameters[6].TypeConfiguration.FullName); Assert.Equal("p7", parameters[7].Name); Assert.Equal(string.Format("Collection({0})", typeof(Employee).FullName), parameters[7].TypeConfiguration.FullName); }