public void IntegrationTest_ApplyRequestsAtSameLevel_FetchOne() { var node1 = new FetchOneExpressionNode(CreateParseInfo(), ExpressionHelper.CreateLambdaExpression <Cook, Cook> (s => s.Substitution)); var node2 = new ThenFetchManyExpressionNode( CreateParseInfo(node1), ExpressionHelper.CreateLambdaExpression <Cook, IEnumerable <Cook> > (s => s.Assistants)); var node3 = new FetchOneExpressionNode(CreateParseInfo(node2), ExpressionHelper.CreateLambdaExpression <Cook, Cook> (s => s.Substitution)); var node4 = new ThenFetchOneExpressionNode(CreateParseInfo(node3), ExpressionHelper.CreateLambdaExpression <Cook, bool> (s => s.IsStarredCook)); node1.Apply(QueryModel, ClauseGenerationContext); node2.Apply(QueryModel, ClauseGenerationContext); node3.Apply(QueryModel, ClauseGenerationContext); node4.Apply(QueryModel, ClauseGenerationContext); Assert.That(QueryModel.ResultOperators.Count, Is.EqualTo(1)); var fetchRequest1 = ((FetchOneRequest)QueryModel.ResultOperators[0]); Assert.That(fetchRequest1.RelationMember, Is.EqualTo(typeof(Cook).GetProperty("Substitution"))); Assert.That(fetchRequest1.InnerFetchRequests.Count(), Is.EqualTo(2)); var fetchRequest2 = ((FetchManyRequest)fetchRequest1.InnerFetchRequests.First()); Assert.That(fetchRequest2.RelationMember, Is.EqualTo(typeof(Cook).GetProperty("Assistants"))); Assert.That(fetchRequest2.InnerFetchRequests.Count(), Is.EqualTo(0)); var fetchRequest3 = ((FetchOneRequest)fetchRequest1.InnerFetchRequests.Skip(1).Single()); Assert.That(fetchRequest3.RelationMember, Is.EqualTo(typeof(Cook).GetProperty("IsStarredCook"))); Assert.That(fetchRequest3.InnerFetchRequests.Count(), Is.EqualTo(0)); }
public void Apply_AddsMappingForExisting() { _node.Apply(QueryModel, ClauseGenerationContext); var node = new ThenFetchOneExpressionNode(CreateParseInfo(_sourceFetchRequestNode), ExpressionHelper.CreateLambdaExpression <Cook, Cook> (s => s.Substitution)); node.Apply(QueryModel, ClauseGenerationContext); var innerFetchRequest = ((FetchRequestBase)QueryModel.ResultOperators[0]).InnerFetchRequests.Single(); Assert.That(ClauseGenerationContext.GetContextInfo(node), Is.SameAs(innerFetchRequest)); }
public override void SetUp() { base.SetUp(); _sourceFetchRequest = new TestFetchRequest(typeof(Cook).GetProperty("Substitution")); _sourceFetchRequestNode = new MainSourceExpressionNode("x", Expression.Constant(new Cook[0])); ClauseGenerationContext.AddContextInfo(_sourceFetchRequestNode, _sourceFetchRequest); QueryModel.ResultOperators.Add(_sourceFetchRequest); _node = new ThenFetchOneExpressionNode(CreateParseInfo(_sourceFetchRequestNode), ExpressionHelper.CreateLambdaExpression <Cook, Cook> (s => s.Substitution)); }
public void Apply_WithoutPreviousFetchRequest() { var node = new ThenFetchOneExpressionNode(CreateParseInfo(), ExpressionHelper.CreateLambdaExpression <Cook, Cook> (s => s.Substitution)); node.Apply(QueryModel, ClauseGenerationContext); }