|
1 |
| -// ------------------------------------------------------------ |
| 1 | +// ------------------------------------------------------------ |
2 | 2 | // Copyright (c) Microsoft Corporation. All rights reserved.
|
3 | 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
|
4 | 4 | // ------------------------------------------------------------
|
@@ -299,6 +299,65 @@ public void CreateOperationForOverloadEdmFunctionReturnsCorrectOperationId(bool
|
299 | 299 | }
|
300 | 300 | }
|
301 | 301 |
|
| 302 | + [Theory] |
| 303 | + [InlineData(true)] |
| 304 | + [InlineData(false)] |
| 305 | + public void CreateOperationForComposableOverloadEdmFunctionReturnsCorrectOperationId(bool enableOperationId) |
| 306 | + { |
| 307 | + // Arrange |
| 308 | + EdmModel model = new(); |
| 309 | + EdmEntityType customer = new("NS", "Customer"); |
| 310 | + customer.AddKeys(customer.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32)); |
| 311 | + model.AddElement(customer); |
| 312 | + |
| 313 | + EdmFunction function = new("NS", "MyFunction", EdmCoreModel.Instance.GetString(false), true, null, false); |
| 314 | + function.AddParameter("entity", new EdmEntityTypeReference(customer, false)); |
| 315 | + function.AddParameter("param", EdmCoreModel.Instance.GetString(false)); |
| 316 | + model.AddElement(function); |
| 317 | + |
| 318 | + function = new EdmFunction("NS", "MyFunction", EdmCoreModel.Instance.GetString(false), true, null, false); |
| 319 | + function.AddParameter("entity", new EdmEntityTypeReference(customer, false)); |
| 320 | + function.AddParameter("param", EdmCoreModel.Instance.GetString(false)); |
| 321 | + function.AddParameter("param2", EdmCoreModel.Instance.GetString(false)); |
| 322 | + model.AddElement(function); |
| 323 | + |
| 324 | + EdmFunction function2 = new("NS", "MyFunction2", EdmCoreModel.Instance.GetString(false), true, null, false); |
| 325 | + function2.AddParameter("entity2", new EdmEntityTypeReference(customer, false)); |
| 326 | + function2.AddParameter("param3", EdmCoreModel.Instance.GetString(false)); |
| 327 | + model.AddElement(function2); |
| 328 | + |
| 329 | + EdmEntityContainer container = new("NS", "Default"); |
| 330 | + EdmEntitySet customers = new(container, "Customers", customer); |
| 331 | + model.AddElement(container); |
| 332 | + |
| 333 | + OpenApiConvertSettings settings = new OpenApiConvertSettings |
| 334 | + { |
| 335 | + EnableOperationId = enableOperationId, |
| 336 | + AddSingleQuotesForStringParameters = true, |
| 337 | + }; |
| 338 | + ODataContext context = new(model, settings); |
| 339 | + |
| 340 | + ODataPath path = new(new ODataNavigationSourceSegment(customers), |
| 341 | + new ODataKeySegment(customer), |
| 342 | + new ODataOperationSegment(function), |
| 343 | + new ODataOperationSegment(function2)); |
| 344 | + |
| 345 | + // Act |
| 346 | + var operation = _operationHandler.CreateOperation(context, path); |
| 347 | + |
| 348 | + // Assert |
| 349 | + Assert.NotNull(operation); |
| 350 | + |
| 351 | + if (enableOperationId) |
| 352 | + { |
| 353 | + Assert.Equal("Customers.Customer.MyFunction.MyFunction2-df74", operation.OperationId); |
| 354 | + } |
| 355 | + else |
| 356 | + { |
| 357 | + Assert.Null(operation.OperationId); |
| 358 | + } |
| 359 | + } |
| 360 | + |
302 | 361 | [Theory]
|
303 | 362 | [InlineData(true)]
|
304 | 363 | [InlineData(false)]
|
|
0 commit comments