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 GetOrCreateFetchQueryModel_ClonesSourceModel_AndResetsResultTypeOverride()
        {
            var fetchQueryModel = _outerFetchQueryModelBuilder.GetOrCreateFetchQueryModel();

            fetchQueryModel.ResultTypeOverride = typeof(List <>);
            var newSourceModel = ((SubQueryExpression)fetchQueryModel.MainFromClause.FromExpression).QueryModel;

            Assert.That(newSourceModel, Is.Not.Null);
            Assert.That(newSourceModel, Is.Not.SameAs(_sourceItemQueryModel));
            Assert.That(newSourceModel.ResultTypeOverride, Is.Null);

            ExpressionTreeComparer.CheckAreEqualTrees(newSourceModel.MainFromClause.FromExpression, _sourceItemQueryModel.MainFromClause.FromExpression);
            Assert.That(newSourceModel.MainFromClause.ItemName, Is.EqualTo(_sourceItemQueryModel.MainFromClause.ItemName));
            Assert.That(newSourceModel.MainFromClause.ItemType, Is.SameAs(_sourceItemQueryModel.MainFromClause.ItemType));
        }