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
// --------------------------------------------------------------
@@ -48,7 +48,7 @@ public void GetPathsForGraphBetaModelReturnsAllPaths()
48
48
49
49
// Assert
50
50
Assert . NotNull ( paths ) ;
51
- Assert . Equal ( 50085 , paths . Count ( ) ) ;
51
+ Assert . Equal ( 28227 , paths . Count ( ) ) ;
52
52
}
53
53
54
54
[ Fact ]
@@ -67,7 +67,7 @@ public void GetPathsForGraphBetaModelWithDerivedTypesConstraintReturnsAllPaths()
67
67
68
68
// Assert
69
69
Assert . NotNull ( paths ) ;
70
- Assert . Equal ( 50070 , paths . Count ( ) ) ;
70
+ Assert . Equal ( 28193 , paths . Count ( ) ) ;
71
71
}
72
72
73
73
[ Fact ]
@@ -271,14 +271,15 @@ public void GetPathsWithBoundActionOperationForContainmentNavigationPropertyPath
271
271
272
272
// Assert
273
273
Assert . NotNull ( paths ) ;
274
- Assert . Equal ( 5 , paths . Count ( ) ) ;
275
274
276
275
if ( containsTarget )
277
276
{
277
+ Assert . Equal ( 5 , paths . Count ( ) ) ;
278
278
Assert . Contains ( "/Customers({ID})/Referral/NS.Ack" , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
279
279
}
280
280
else
281
281
{
282
+ Assert . Equal ( 4 , paths . Count ( ) ) ;
282
283
Assert . DoesNotContain ( "/Customers({ID})/Referral/NS.Ack" , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
283
284
}
284
285
}
@@ -308,14 +309,15 @@ public void GetPathsWithBoundFunctionOperationForContainmentNavigationPropertyPa
308
309
309
310
// Assert
310
311
Assert . NotNull ( paths ) ;
311
- Assert . Equal ( 5 , paths . Count ( ) ) ;
312
312
313
313
if ( containsTarget )
314
314
{
315
+ Assert . Equal ( 5 , paths . Count ( ) ) ;
315
316
Assert . Contains ( "/Customers({ID})/Referral/NS.Search()" , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
316
317
}
317
318
else
318
319
{
320
+ Assert . Equal ( 4 , paths . Count ( ) ) ;
319
321
Assert . DoesNotContain ( "/Customers({ID})/Referral/NS.Search()" , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
320
322
}
321
323
}
@@ -380,7 +382,7 @@ public void GetPathsWithFalseNavigabilityInNavigationRestrictionsAnnotationWorks
380
382
381
383
// Assert
382
384
Assert . NotNull ( paths ) ;
383
- Assert . Equal ( 10 , paths . Count ( ) ) ;
385
+ Assert . Equal ( 9 , paths . Count ( ) ) ;
384
386
385
387
var pathItems = paths . Select ( p => p . GetPathItemName ( ) ) . ToList ( ) ;
386
388
Assert . DoesNotContain ( "/Orders({id})/SingleCustomer" , pathItems ) ;
@@ -423,23 +425,35 @@ public void GetPathsWithFalseIndexabilityByKeyInNavigationRestrictionsAnnotation
423
425
424
426
// Assert
425
427
Assert . NotNull ( paths ) ;
426
- Assert . Equal ( 9 , paths . Count ( ) ) ;
428
+ Assert . Equal ( 8 , paths . Count ( ) ) ;
427
429
428
430
var pathItems = paths . Select ( p => p . GetPathItemName ( ) ) . ToList ( ) ;
429
431
Assert . DoesNotContain ( "/Orders({id})/MultipleCustomers({ID})" , pathItems ) ;
430
432
}
431
433
432
434
[ Fact ]
433
- public void GetPathsWithNonContainedNavigationPropertyWorks ( )
435
+ public void GetPathsWithReferenceableNavigationPropertyWorks ( )
434
436
{
435
437
// Arrange
436
438
string entityType =
437
439
@"<EntityType Name=""Order"">
438
440
<Key>
439
441
<PropertyRef Name=""id"" />
440
442
</Key>
441
- <NavigationProperty Name=""MultipleCustomers"" Type=""Collection(NS.Customer)"" />
442
- <NavigationProperty Name=""SingleCustomer"" Type=""NS.Customer"" />
443
+ <NavigationProperty Name=""MultipleCustomers"" Type=""Collection(NS.Customer)"">
444
+ <Annotation Term=""Org.OData.Capabilities.V1.NavigationRestrictions"">
445
+ <Record>
446
+ <PropertyValue Property=""Referenceable"" Bool=""true"" />
447
+ </Record>
448
+ </Annotation>
449
+ </NavigationProperty>
450
+ <NavigationProperty Name=""SingleCustomer"" Type=""NS.Customer"">
451
+ <Annotation Term=""Org.OData.Capabilities.V1.NavigationRestrictions"">
452
+ <Record>
453
+ <PropertyValue Property=""Referenceable"" Bool=""true"" />
454
+ </Record>
455
+ </Annotation>
456
+ </NavigationProperty>
443
457
</EntityType>" ;
444
458
445
459
string entitySet = @"<EntitySet Name=""Orders"" EntityType=""NS.Order"" />" ;
@@ -463,6 +477,40 @@ public void GetPathsWithNonContainedNavigationPropertyWorks()
463
477
Assert . Contains ( "/Orders({id})/MultipleCustomers({ID})/$ref" , pathItems ) ;
464
478
}
465
479
480
+ [ Fact ]
481
+ public void GetPathsWithNonReferenceableNavigationPropertyWorks ( )
482
+ {
483
+ // Arrange
484
+ string entityType =
485
+ @"<EntityType Name=""Order"">
486
+ <Key>
487
+ <PropertyRef Name=""id"" />
488
+ </Key>
489
+ <NavigationProperty Name=""MultipleCustomers"" Type=""Collection(NS.Customer)"" />
490
+ <NavigationProperty Name=""SingleCustomer"" Type=""NS.Customer"" />
491
+ </EntityType>" ;
492
+
493
+ string entitySet = @"<EntitySet Name=""Orders"" EntityType=""NS.Order"" />" ;
494
+ IEdmModel model = GetEdmModel ( entityType , entitySet ) ;
495
+
496
+ ODataPathProvider provider = new ODataPathProvider ( ) ;
497
+ var settings = new OpenApiConvertSettings ( ) ;
498
+
499
+ // Act
500
+ var paths = provider . GetPaths ( model , settings ) ;
501
+
502
+ // Assert
503
+ Assert . NotNull ( paths ) ;
504
+ Assert . Equal ( 10 , paths . Count ( ) ) ;
505
+
506
+ var pathItems = paths . Select ( p => p . GetPathItemName ( ) ) . ToList ( ) ;
507
+ Assert . Contains ( "/Orders({id})/MultipleCustomers" , pathItems ) ;
508
+ Assert . Contains ( "/Orders({id})/SingleCustomer" , pathItems ) ;
509
+ Assert . Contains ( "/Orders({id})/SingleCustomer" , pathItems ) ;
510
+ Assert . Contains ( "/Orders({id})/MultipleCustomers" , pathItems ) ;
511
+ Assert . Contains ( "/Orders({id})/MultipleCustomers({ID})" , pathItems ) ;
512
+ }
513
+
466
514
[ Fact ]
467
515
public void GetPathsWithContainedNavigationPropertyWorks ( )
468
516
{
@@ -522,22 +570,22 @@ public void GetPathsWithStreamPropertyAndWithEntityHasStreamWorks(bool hasStream
522
570
{
523
571
if ( hasStream )
524
572
{
525
- Assert . Equal ( 15 , paths . Count ( ) ) ;
573
+ Assert . Equal ( 14 , paths . Count ( ) ) ;
526
574
Assert . Contains ( TodosValuePath , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
527
575
Assert . Contains ( TodosLogoPath , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
528
576
Assert . DoesNotContain ( TodosContentPath , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
529
577
}
530
578
else
531
579
{
532
- Assert . Equal ( 14 , paths . Count ( ) ) ;
580
+ Assert . Equal ( 13 , paths . Count ( ) ) ;
533
581
Assert . Contains ( TodosLogoPath , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
534
582
Assert . DoesNotContain ( TodosContentPath , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
535
583
Assert . DoesNotContain ( TodosValuePath , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
536
584
}
537
585
}
538
586
else if ( streamPropName . Equals ( "content" ) )
539
587
{
540
- Assert . Equal ( 14 , paths . Count ( ) ) ;
588
+ Assert . Equal ( 13 , paths . Count ( ) ) ;
541
589
Assert . Contains ( TodosContentPath , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
542
590
Assert . DoesNotContain ( TodosLogoPath , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
543
591
Assert . DoesNotContain ( TodosValuePath , paths . Select ( p => p . GetPathItemName ( ) ) ) ;
0 commit comments