Skip to content

Commit

Permalink
Clean up test case to the assertion makes sense
Browse files Browse the repository at this point in the history
  • Loading branch information
ificator authored and xuzhg committed Jul 12, 2024
1 parent fafad0a commit ff2cd8e
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ public void ProjectAsWrapper_Collection_TopOnNullExpand()
// Arrange
_settings.HandleNullPropagation = HandleNullPropagationOption.True;

IEdmEntityType vipCustomer = _model.SchemaElements.OfType<IEdmEntityType>().First(c => c.Name == "QueryVipCustomer");
IEdmNavigationProperty specialOrdersNav = vipCustomer.DeclaredNavigationProperties().Single(c => c.Name == "SpecialOrders");
IEdmEntityType vipCustomer = _model.SchemaElements.OfType<IEdmEntityType>().First(c => c.Name == nameof(QueryVipCustomer));
IEdmNavigationProperty specialOrdersNav = vipCustomer.DeclaredNavigationProperties().Single(c => c.Name == nameof(QueryVipCustomer.SpecialOrders));
ExpandedNavigationSelectItem expandItem = new ExpandedNavigationSelectItem(
new ODataExpandPath(new NavigationPropertySegment(specialOrdersNav, navigationSource: _orders)),
_orders,
Expand All @@ -317,8 +317,12 @@ public void ProjectAsWrapper_Collection_TopOnNullExpand()
Expression projection = _binder.ProjectAsWrapper(source, selectExpand, vipCustomer, _customers);

// Assert
IEnumerable<SelectExpandWrapper<QueryOrder>> projectedOrders = Expression.Lambda(projection).Compile().DynamicInvoke() as IEnumerable<SelectExpandWrapper<QueryOrder>>;
Assert.Null(projectedOrders);
object rawProjectionResult = Expression.Lambda(projection).Compile().DynamicInvoke();
Assert.NotNull(rawProjectionResult);
SelectExpandWrapper<QueryVipCustomer> projectedCustomer = rawProjectionResult as SelectExpandWrapper<QueryVipCustomer>;
Assert.NotNull(projectedCustomer);
Assert.True(projectedCustomer.TryGetPropertyValue(nameof(QueryVipCustomer.SpecialOrders), out object rawSpecialOrders));
Assert.Null(rawSpecialOrders);
}

[Fact]
Expand Down

0 comments on commit ff2cd8e

Please sign in to comment.