private void CheckFetchQueryModelBuilder(
     FetchQueryModelBuilder builder, FetchRequestBase expectedFetchRequest, QueryModel expectedQueryModel, int expectedResultOperatorPosition)
 {
     Assert.That(builder.FetchRequest, Is.SameAs(expectedFetchRequest));
     Assert.That(builder.SourceItemQueryModel, Is.SameAs(expectedQueryModel));
     Assert.That(builder.ResultOperatorPosition, Is.EqualTo(expectedResultOperatorPosition));
 }
        public void GetOrCreateFetchQueryModel_CallsCreateFetchQueryModel()
        {
            var fetchRequestMock = MockRepository.GenerateMock <FetchRequestBase> (_friendsMember);
            var mockQueryModel   = ExpressionHelper.CreateQueryModel <Cook> ();

            fetchRequestMock.Expect(mock => mock.CreateFetchQueryModel(Arg <QueryModel> .Is.Anything)).Return(mockQueryModel);

            var builder = new FetchQueryModelBuilder(fetchRequestMock, _sourceItemQueryModel, 1);
            var result  = builder.GetOrCreateFetchQueryModel();

            Assert.That(result, Is.SameAs(mockQueryModel));
        }
        public void SetUp()
        {
            _friendsMember = typeof(Cook).GetProperty("Assistants");
            _hasDogMember  = typeof(Cook).GetProperty("IsStarredCook");
            _scoresMember  = typeof(Cook).GetProperty("Holidays");
            _isOldMember   = typeof(Cook).GetProperty("IsFullTimeCook");

            _outerFetchRequest  = new TestFetchRequest(_friendsMember);
            _innerFetchRequest1 = new TestFetchRequest(_hasDogMember);
            _outerFetchRequest.GetOrAddInnerFetchRequest(_innerFetchRequest1);
            _innerFetchRequest2 = new TestFetchRequest(_scoresMember);
            _outerFetchRequest.GetOrAddInnerFetchRequest(_innerFetchRequest2);
            _innerInnerFetchRequest = new TestFetchRequest(_isOldMember);
            _innerFetchRequest1.GetOrAddInnerFetchRequest(_innerInnerFetchRequest);

            var expression = ExpressionHelper.MakeExpression(() => (from sd in ExpressionHelper.CreateQueryable <Kitchen> ()
                                                                    select sd.Cook).Take(1) /*.Fetch*/.Distinct().Count());

            _sourceItemQueryModel        = ExpressionHelper.ParseQuery(expression);
            _outerFetchQueryModelBuilder = new FetchQueryModelBuilder(_outerFetchRequest, _sourceItemQueryModel, 1);
        }