public void VisitResultOperator_NoHandlerFound()
        {
            var resultOperator    = new TestChoiceResultOperator(false);
            var registry          = new ResultOperatorHandlerRegistry();
            var queryModelVisitor = new TestableSqlPreparationQueryModelVisitor(_context, _stageMock, _generator, registry);

            queryModelVisitor.VisitResultOperator(resultOperator, _queryModel, 0);
        }
 public IDomainObjectQueryGenerator CreateDomainObjectQueryGenerator(
     StorageProviderDefinition storageProviderDefinition,
     IMethodCallTransformerProvider methodCallTransformerProvider,
     ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
     IMappingConfiguration mappingConfiguration)
 {
     return(new StubDomainObjectQueryGenerator());
 }
    public void GetItem_NotFound ()
    {
      var registry = new ResultOperatorHandlerRegistry ();

      var result = registry.GetItem (typeof (InheritedResultOperator));

      Assert.That (result, Is.Null);
    }
예제 #4
0
 public IDomainObjectQueryGenerator CreateDomainObjectQueryGenerator(
     StorageProviderDefinition storageProviderDefinition,
     IMethodCallTransformerProvider methodCallTransformerProvider,
     ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
     IMappingConfiguration mappingConfiguration)
 {
     throw new NotImplementedException();
 }
예제 #5
0
 public void SetUp()
 {
     _generator = new UniqueIdentifierGenerator();
     _stageMock = new DefaultSqlPreparationStage(
         CompoundMethodCallTransformerProvider.CreateDefault(), ResultOperatorHandlerRegistry.CreateDefault(), _generator);
     _handler             = new OfTypeResultOperatorHandler();
     _sqlStatementBuilder = new SqlStatementBuilder(SqlStatementModelObjectMother.CreateSqlStatementWithCook());
     _context             = SqlStatementModelObjectMother.CreateSqlPreparationContext();
 }
    public void GetItem_ForBaseResultOperator ()
    {
      var registry = new ResultOperatorHandlerRegistry ();
      var handlerMock = MockRepository.GenerateMock<IResultOperatorHandler> ();
      registry.Register (typeof (ResultOperatorBase), handlerMock);

      var result = registry.GetItem (typeof (InheritedResultOperator));

      Assert.That (result, Is.SameAs (handlerMock));
    }
        public void GetItem_ForBaseResultOperator()
        {
            var registry    = new ResultOperatorHandlerRegistry();
            var handlerMock = MockRepository.GenerateMock <IResultOperatorHandler> ();

            registry.Register(typeof(ResultOperatorBase), handlerMock);

            var result = registry.GetItem(typeof(InheritedResultOperator));

            Assert.That(result, Is.SameAs(handlerMock));
        }
예제 #8
0
 public void SetUp()
 {
     _generator = new UniqueIdentifierGenerator();
     _stage     = new DefaultSqlPreparationStage(
         CompoundMethodCallTransformerProvider.CreateDefault(), ResultOperatorHandlerRegistry.CreateDefault(), _generator);
     _handler             = new DefaultIfEmptyResultOperatorHandler();
     _sqlStatementBuilder = new SqlStatementBuilder(SqlStatementModelObjectMother.CreateSqlStatement())
     {
         DataInfo = new StreamedSequenceInfo(typeof(Cook[]), Expression.Constant(new Cook()))
     };
     _context = SqlStatementModelObjectMother.CreateSqlPreparationContext();
 }
        public void TransformQueryModel_EmptyQueryModel()
        {
            var result = SqlPreparationQueryModelVisitor.TransformQueryModel(
                _queryModel, _context, _defaultStage, _generator, ResultOperatorHandlerRegistry.CreateDefault());

            Assert.That(result.SelectProjection, Is.TypeOf(typeof(NamedExpression)));
            Assert.That(result.WhereCondition, Is.Null);
            Assert.That(result.SqlTables.Count, Is.EqualTo(1));
            Assert.That(((SqlTable)result.SqlTables[0]).TableInfo, Is.InstanceOf(typeof(UnresolvedTableInfo)));
            Assert.That(result.TopExpression, Is.Null);
            Assert.That(result.IsDistinctQuery, Is.False);
        }
    public DefaultSqlPreparationStage (
        IMethodCallTransformerProvider methodCallTransformerProvider,
        ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
        UniqueIdentifierGenerator uniqueIdentifierGenerator)
    {
      ArgumentUtility.CheckNotNull ("methodCallTransformerProvider", methodCallTransformerProvider);
      ArgumentUtility.CheckNotNull ("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);
      ArgumentUtility.CheckNotNull ("uniqueIdentifierGenerator", uniqueIdentifierGenerator);

      _methodCallTransformerProvider = methodCallTransformerProvider;
      _resultOperatorHandlerRegistry = resultOperatorHandlerRegistry;
      _uniqueIdentifierGenerator = uniqueIdentifierGenerator;
    }
        public void CreateDefault()
        {
            var registry = ResultOperatorHandlerRegistry.CreateDefault();

            Assert.That(registry.GetItem(typeof(CastResultOperator)), Is.TypeOf(typeof(CastResultOperatorHandler)));
            Assert.That(registry.GetItem(typeof(ContainsResultOperator)), Is.TypeOf(typeof(ContainsResultOperatorHandler)));
            Assert.That(registry.GetItem(typeof(CountResultOperator)), Is.TypeOf(typeof(CountResultOperatorHandler)));
            Assert.That(registry.GetItem(typeof(DistinctResultOperator)), Is.TypeOf(typeof(DistinctResultOperatorHandler)));
            Assert.That(registry.GetItem(typeof(FirstResultOperator)), Is.TypeOf(typeof(FirstResultOperatorHandler)));
            Assert.That(registry.GetItem(typeof(OfTypeResultOperator)), Is.TypeOf(typeof(OfTypeResultOperatorHandler)));
            Assert.That(registry.GetItem(typeof(SingleResultOperator)), Is.TypeOf(typeof(SingleResultOperatorHandler)));
            Assert.That(registry.GetItem(typeof(TakeResultOperator)), Is.TypeOf(typeof(TakeResultOperatorHandler)));
            Assert.That(registry.GetItem(typeof(AnyResultOperator)), Is.TypeOf(typeof(AnyResultOperatorHandler)));
        }
        public void TransformQueryModel_QueryModel_WithAdditionalClauses()
        {
            var constantExpression   = Expression.Constant(new Cook[0]);
            var additionalFromClause = new AdditionalFromClause("additional", typeof(int), constantExpression);

            _queryModel.BodyClauses.Add(additionalFromClause);
            _queryModel.BodyClauses.Add(ExpressionHelper.CreateWhereClause());
            _queryModel.ResultOperators.Add(new CountResultOperator());

            var result = SqlPreparationQueryModelVisitor.TransformQueryModel(
                _queryModel, _context, _defaultStage, _generator, ResultOperatorHandlerRegistry.CreateDefault());

            Assert.That(result.WhereCondition, Is.Not.Null);
            Assert.That(result.SqlTables.Count, Is.EqualTo(2));
        }
        public void SetUp()
        {
            _context = SqlStatementModelObjectMother.CreateSqlPreparationContext();

            var querySource = ExpressionHelper.CreateMainFromClause <Cook>();

            _sqlTable = new SqlTable(new UnresolvedTableInfo(typeof(Cook)), JoinSemantics.Inner);

            _context.AddExpressionMapping(new QuerySourceReferenceExpression(querySource), new SqlTableReferenceExpression(_sqlTable));

            _querySourceReferenceExpression = new QuerySourceReferenceExpression(querySource);

            _stage = new DefaultSqlPreparationStage(
                CompoundMethodCallTransformerProvider.CreateDefault(), ResultOperatorHandlerRegistry.CreateDefault(), new UniqueIdentifierGenerator());
        }
        public void SetUp()
        {
            _generator    = new UniqueIdentifierGenerator();
            _context      = SqlStatementModelObjectMother.CreateSqlPreparationContext();
            _defaultStage = new DefaultSqlPreparationStage(
                CompoundMethodCallTransformerProvider.CreateDefault(), ResultOperatorHandlerRegistry.CreateDefault(), _generator);

            _mainFromClause = ExpressionHelper.CreateMainFromClause <Cook>();
            _selectClause   = ExpressionHelper.CreateSelectClause(_mainFromClause);
            _orderByClause  = ExpressionHelper.CreateOrderByClause();
            _queryModel     = new QueryModel(_mainFromClause, _selectClause);

            _stageMock          = MockRepository.GenerateStrictMock <ISqlPreparationStage>();
            _visitor            = new TestableSqlPreparationQueryModelVisitor(_context, _stageMock);
            _visitorPartialMock = MockRepository.GeneratePartialMock <TestableSqlPreparationQueryModelVisitor> (_context, _stageMock);
        }
        public ISqlQueryGenerator CreateSqlQueryGenerator(
            RdbmsProviderDefinition storageProviderDefinition,
            IMethodCallTransformerProvider methodCallTransformerProvider,
            ResultOperatorHandlerRegistry resultOperatorHandlerRegistry)
        {
            ArgumentUtility.CheckNotNull("storageProviderDefinition", storageProviderDefinition);
            ArgumentUtility.CheckNotNull("methodCallTransformerProvider", methodCallTransformerProvider);
            ArgumentUtility.CheckNotNull("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);

            var persistenceModelProvider = CreateRdbmsPersistenceModelProvider(storageProviderDefinition);

            return(CreateSqlQueryGenerator(
                       storageProviderDefinition,
                       methodCallTransformerProvider,
                       resultOperatorHandlerRegistry,
                       persistenceModelProvider));
        }
    protected SqlPreparationQueryModelVisitor (
        ISqlPreparationContext parentContext,
        ISqlPreparationStage stage,
        UniqueIdentifierGenerator generator,
        ResultOperatorHandlerRegistry resultOperatorHandlerRegistry)
    {
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("generator", generator);
      ArgumentUtility.CheckNotNull ("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);

      _stage = stage;
      _generator = generator;
      _resultOperatorHandlerRegistry = resultOperatorHandlerRegistry;

      _sqlStatementBuilder = new SqlStatementBuilder();
      _context = new SqlPreparationContext (parentContext, _sqlStatementBuilder);
    }
    public static SqlStatement TransformQueryModel (
        QueryModel queryModel,
        ISqlPreparationContext parentPreparationContext,
        ISqlPreparationStage stage,
        UniqueIdentifierGenerator generator,
        ResultOperatorHandlerRegistry resultOperatorHandlerRegistry)
    {
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("generator", generator);
      ArgumentUtility.CheckNotNull ("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);

      var visitor = new SqlPreparationQueryModelVisitor (parentPreparationContext, stage, generator, resultOperatorHandlerRegistry);
      queryModel.Accept (visitor);

      return visitor.GetSqlStatement();
    }
        public void SetUp()
        {
            _rdbmsProviderDefinition         = new RdbmsProviderDefinition("TestDomain", new SqlStorageObjectFactory(), "ConnectionString");
            _sqlProviderFactory              = new SqlStorageObjectFactory();
            _persistenceExtensionStub        = MockRepository.GenerateStub <IPersistenceExtension>();
            _storageProviderDefinitionFinder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage);

            _tableBuilderStub = MockRepository.GenerateStub <TableScriptBuilder> (
                MockRepository.GenerateStub <ITableScriptElementFactory>(), new SqlCommentScriptElementFactory());
            _viewBuilderStub = MockRepository.GenerateStub <ViewScriptBuilder> (
                MockRepository.GenerateStub <IViewScriptElementFactory <TableDefinition> >(),
                MockRepository.GenerateStub <IViewScriptElementFactory <UnionViewDefinition> >(),
                MockRepository.GenerateStub <IViewScriptElementFactory <FilterViewDefinition> >(),
                MockRepository.GenerateStub <IViewScriptElementFactory <EmptyViewDefinition> >(),
                new SqlCommentScriptElementFactory());
            _constraintBuilderStub =
                MockRepository.GenerateStub <ForeignKeyConstraintScriptBuilder> (
                    MockRepository.GenerateStub <IForeignKeyConstraintScriptElementFactory>(), new SqlCommentScriptElementFactory());
            _indexScriptElementFactoryStub = MockRepository.GenerateStub <SqlIndexScriptElementFactory> (
                MockRepository.GenerateStub <ISqlIndexDefinitionScriptElementFactory <SqlIndexDefinition> >(),
                MockRepository.GenerateStub <ISqlIndexDefinitionScriptElementFactory <SqlPrimaryXmlIndexDefinition> >(),
                MockRepository.GenerateStub <ISqlIndexDefinitionScriptElementFactory <SqlSecondaryXmlIndexDefinition> >());
            _indexBuilderStub   = MockRepository.GenerateStub <IndexScriptBuilder> (_indexScriptElementFactoryStub, new SqlCommentScriptElementFactory());
            _synonymBuilderStub =
                MockRepository.GenerateStub <SynonymScriptBuilder> (
                    MockRepository.GenerateStub <ISynonymScriptElementFactory <TableDefinition> >(),
                    MockRepository.GenerateStub <ISynonymScriptElementFactory <UnionViewDefinition> >(),
                    MockRepository.GenerateStub <ISynonymScriptElementFactory <FilterViewDefinition> >(),
                    MockRepository.GenerateStub <ISynonymScriptElementFactory <EmptyViewDefinition> >(),
                    new SqlCommentScriptElementFactory());
            _rdbmsPersistenceModelProviderStub  = MockRepository.GenerateStub <IRdbmsPersistenceModelProvider>();
            _storageTypeInformationProviderStub = MockRepository.GenerateStub <IStorageTypeInformationProvider>();
            _dbCommandBuilderFactoryStub        = MockRepository.GenerateStub <IDbCommandBuilderFactory>();
            MockRepository.GeneratePartialMock <SqlSynonymScriptElementFactory>();
            _storageNameProviderStub = MockRepository.GenerateStub <IStorageNameProvider>();
            _infrastructureStoragePropertyDefinitionProviderStub = MockRepository.GenerateStub <IInfrastructureStoragePropertyDefinitionProvider>();
            _dataStoragePropertyDefinitionFactoryStub            = MockRepository.GenerateStub <IDataStoragePropertyDefinitionFactory>();
            _valueStoragePropertyDefinitonFactoryStub            = MockRepository.GenerateStub <IValueStoragePropertyDefinitionFactory>();
            _relationStoragePropertyDefiniitonFactoryStub        = MockRepository.GenerateStub <IRelationStoragePropertyDefinitionFactory>();
            _methodCallTransformerProviderStub  = MockRepository.GenerateStub <IMethodCallTransformerProvider>();
            _resultOpertatorHandlerRegistryStub = MockRepository.GeneratePartialMock <ResultOperatorHandlerRegistry>();
            _sqlQueryGeneratorStub = MockRepository.GenerateStub <ISqlQueryGenerator>();
            _foreignKeyConstraintDefinitionFactoryStub = MockRepository.GenerateStub <IForeignKeyConstraintDefinitionFactory>();
            _storagePropertyDefinitionResolverStub     = MockRepository.GenerateStub <IStoragePropertyDefinitionResolver>();
        }
        public virtual IDomainObjectQueryGenerator CreateDomainObjectQueryGenerator(
            StorageProviderDefinition storageProviderDefinition,
            IMethodCallTransformerProvider methodCallTransformerProvider,
            ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
            IMappingConfiguration mappingConfiguration)
        {
            var rdmsStorageProviderDefinition =
                ArgumentUtility.CheckNotNullAndType <RdbmsProviderDefinition> ("storageProviderDefinition", storageProviderDefinition);

            ArgumentUtility.CheckNotNull("methodCallTransformerProvider", methodCallTransformerProvider);
            ArgumentUtility.CheckNotNull("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);
            ArgumentUtility.CheckNotNull("mappingConfiguration", mappingConfiguration);

            var storageTypeInformationProvider = CreateStorageTypeInformationProvider(rdmsStorageProviderDefinition);
            var sqlQueryGenerator = CreateSqlQueryGenerator(rdmsStorageProviderDefinition, methodCallTransformerProvider, resultOperatorHandlerRegistry);

            return(ObjectFactory.Create <DomainObjectQueryGenerator> (
                       ParamList.Create(sqlQueryGenerator, _typeConversionProvider, storageTypeInformationProvider, mappingConfiguration)));
        }
예제 #20
0
        protected SqlCommandData GenerateSql(QueryModel queryModel)
        {
            var generator = new UniqueIdentifierGenerator();

            var resultOperatorHandlerRegistry = ResultOperatorHandlerRegistry.CreateDefault();
            var defaultSqlPreparationStage    = new DefaultSqlPreparationStage(CompoundMethodCallTransformerProvider.CreateDefault(), resultOperatorHandlerRegistry, generator);
            var sqlStatement = defaultSqlPreparationStage.PrepareSqlStatement(queryModel, null);

            var resolver = new MappingResolverStub();
            var mappingResolutionStage   = new DefaultMappingResolutionStage(resolver, generator);
            var mappingResolutionContext = new MappingResolutionContext();
            var newSqlStatement          = mappingResolutionStage.ResolveSqlStatement(sqlStatement, mappingResolutionContext);

            var commandBuilder     = new SqlCommandBuilder();
            var sqlGenerationStage = new DefaultSqlGenerationStage();

            sqlGenerationStage.GenerateTextForOuterSqlStatement(commandBuilder, newSqlStatement);

            return(commandBuilder.GetCommand());
        }
        protected virtual ISqlQueryGenerator CreateSqlQueryGenerator(
            RdbmsProviderDefinition storageProviderDefinition,
            IMethodCallTransformerProvider methodCallTransformerProvider,
            ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
            IRdbmsPersistenceModelProvider persistenceModelProvider)
        {
            ArgumentUtility.CheckNotNull("storageProviderDefinition", storageProviderDefinition);
            ArgumentUtility.CheckNotNull("methodCallTransformerProvider", methodCallTransformerProvider);
            ArgumentUtility.CheckNotNull("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);
            ArgumentUtility.CheckNotNull("persistenceModelProvider", persistenceModelProvider);

            var generator           = new UniqueIdentifierGenerator();
            var resolver            = CreateMappingResolver(storageProviderDefinition, persistenceModelProvider);
            var sqlPreparationStage = ObjectFactory.Create <DefaultSqlPreparationStage> (
                ParamList.Create(methodCallTransformerProvider, resultOperatorHandlerRegistry, generator));
            var mappingResolutionStage = ObjectFactory.Create <DefaultMappingResolutionStage> (ParamList.Create(resolver, generator));
            var sqlGenerationStage     = ObjectFactory.Create <ExtendedSqlGenerationStage> (ParamList.Empty);

            return(new SqlQueryGenerator(sqlPreparationStage, mappingResolutionStage, sqlGenerationStage));
        }
예제 #22
0
        public QueryExecutor(
            IMappingResolver mappingResolver,
            IQueryResultRetriever resultRetriever,
            ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
            CompoundMethodCallTransformerProvider methodCallTransformerProvider,
            bool showQuery)
        {
            ArgumentUtility.CheckNotNull("mappingResolver", mappingResolver);
            ArgumentUtility.CheckNotNull("resultRetriever", resultRetriever);
            ArgumentUtility.CheckNotNull("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);
            ArgumentUtility.CheckNotNull("methodCallTransformerProvider", methodCallTransformerProvider);

            _mappingResolver = mappingResolver;
            _resultRetriever = resultRetriever;

            _resultOperatorHandlerRegistry = resultOperatorHandlerRegistry;
            _methodCallTransformerProvider = methodCallTransformerProvider;

            _showQuery = showQuery;
        }
예제 #23
0
        public RelinqNorthwindDataProvider()
        {
            _manager   = new NorthwindConnectionManager();
            _context   = new NorthwindDataContext(_manager.GetConnectionString());
            _resolver  = new MappingResolver(_context.Mapping);
            _retriever = new QueryResultRetriever(_manager, _resolver);

            _resultOperatorHandlerRegistry = ResultOperatorHandlerRegistry.CreateDefault();

            var methodBasedTransformerRegistry = MethodInfoBasedMethodCallTransformerRegistry.CreateDefault();
            var nameBasedTransformerRegistry   = NameBasedMethodCallTransformerRegistry.CreateDefault();

            _methodCallTransformerProvider = new CompoundMethodCallTransformerProvider(methodBasedTransformerRegistry, nameBasedTransformerRegistry);
            methodBasedTransformerRegistry.Register(
                typeof(SqlMethods).GetMethod("Like", new[] { typeof(string), typeof(string) }),
                new LikeMethodCallTransformer());
            methodBasedTransformerRegistry.Register(DateDiffDayMethodCallTransformer.SupportedMethods, new DateDiffDayMethodCallTransformer());

            foreach (var userDefinedFunction in _context.GetType().GetMethods().Where(mi => mi.IsDefined(typeof(FunctionAttribute), false)))
            {
                methodBasedTransformerRegistry.Register(userDefinedFunction, new UserDefinedFunctionTransformer());
            }

            var customNodeTypeRegistry = new MethodInfoBasedNodeTypeRegistry();

            customNodeTypeRegistry.Register(new[] { typeof(EntitySet <>).GetMethod("Contains") }, typeof(ContainsExpressionNode));

            var nodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider();

            nodeTypeProvider.InnerProviders.Add(customNodeTypeRegistry);

            var transformerRegistry  = ExpressionTransformerRegistry.CreateDefault();
            var processor            = ExpressionTreeParser.CreateDefaultProcessor(transformerRegistry);
            var expressionTreeParser = new ExpressionTreeParser(nodeTypeProvider, processor);

            _queryParser = new QueryParser(expressionTreeParser);

            _executor = new QueryExecutor(_resolver, _retriever, _resultOperatorHandlerRegistry, _methodCallTransformerProvider, false);
        }
예제 #24
0
 public void SetUp()
 {
     _generator           = new UniqueIdentifierGenerator();
     _stage               = new DefaultSqlPreparationStage(CompoundMethodCallTransformerProvider.CreateDefault(), ResultOperatorHandlerRegistry.CreateDefault(), _generator);
     _handler             = new TestableAggregationResultOperatorHandler();
     _sqlStatementBuilder = new SqlStatementBuilder(SqlStatementModelObjectMother.CreateSqlStatement())
     {
         DataInfo         = new StreamedSequenceInfo(typeof(int[]), Expression.Constant(5)),
         SelectProjection = new NamedExpression(null, Expression.Constant(0))
     };
     _context = SqlStatementModelObjectMother.CreateSqlPreparationContext();
 }
예제 #25
0
 private QueryExecutor CreateQueryExecutor(IQueryResultRetriever retrieverMock)
 {
     return(new QueryExecutor(_resolverStub, retrieverMock, ResultOperatorHandlerRegistry.CreateDefault(), CompoundMethodCallTransformerProvider.CreateDefault(), false));
 }
 public TestableSqlPreparationQueryModelVisitor (ISqlPreparationContext context, ISqlPreparationStage stage,UniqueIdentifierGenerator generator, ResultOperatorHandlerRegistry registry)
   : base (context, stage, generator, registry)
 {
 }
 protected override ISqlQueryGenerator CreateSqlQueryGenerator(RdbmsProviderDefinition storageProviderDefinition, IMethodCallTransformerProvider methodCallTransformerProvider, ResultOperatorHandlerRegistry resultOperatorHandlerRegistry, IRdbmsPersistenceModelProvider persistenceModelProvider)
 {
     return(_sqlQueryGenerator ?? base.CreateSqlQueryGenerator(storageProviderDefinition, methodCallTransformerProvider, resultOperatorHandlerRegistry, persistenceModelProvider));
 }
 public ISqlQueryGenerator CreateSqlQueryGenerator(RdbmsProviderDefinition storageProviderDefinition, IMethodCallTransformerProvider methodCallTransformerProvider, ResultOperatorHandlerRegistry resultOperatorHandlerRegistry)
 {
     throw new NotImplementedException();
 }
 public TestableSqlPreparationQueryModelVisitor(ISqlPreparationContext context, ISqlPreparationStage stage)
     : base(context, stage, new UniqueIdentifierGenerator(), ResultOperatorHandlerRegistry.CreateDefault())
 {
 }
 public TestableSqlPreparationQueryModelVisitor(ISqlPreparationContext context, ISqlPreparationStage stage, UniqueIdentifierGenerator generator, ResultOperatorHandlerRegistry registry)
     : base(context, stage, generator, registry)
 {
 }
    public void VisitQueryModel_ConstantExpressionCollection_VisitResultOperatorsIsCalled ()
    {
      var handlerMock = MockRepository.GenerateStrictMock<IResultOperatorHandler>();
      var registry = new ResultOperatorHandlerRegistry();
      registry.Register (typeof (TestChoiceResultOperator), handlerMock);
      var queryModelVisitor = new TestableSqlPreparationQueryModelVisitor (_context, _stageMock, _generator, registry);

      var constantExpression = Expression.Constant (new[] { "t1", "t2" });
      _queryModel.MainFromClause.FromExpression = constantExpression;
      var resultOperator = new TestChoiceResultOperator (false);
      _queryModel.ResultOperators.Add (resultOperator);
      var sqlStatementBuilder = queryModelVisitor.SqlStatementBuilder;

      handlerMock.Expect (
          mock =>
          mock.HandleResultOperator (
              Arg<ResultOperatorBase>.Matches (o => o == resultOperator),
              Arg<SqlStatementBuilder>.Matches (sb => sb == sqlStatementBuilder),
              Arg<UniqueIdentifierGenerator>.Matches (g => g == _generator),
              Arg<ISqlPreparationStage>.Matches (s => s == _stageMock),
              Arg<ISqlPreparationContext>.Matches (c => c != _context)));
      handlerMock.Replay();

      queryModelVisitor.VisitQueryModel (_queryModel);

      handlerMock.VerifyAllExpectations();
    }
    public void VisitResultOperator_HandlesResultOperator ()
    {
      var resultOperator = new TestChoiceResultOperator (false);

      var handlerMock = MockRepository.GenerateMock<IResultOperatorHandler>();
      
      var registry = new ResultOperatorHandlerRegistry();
      registry.Register (typeof (TestChoiceResultOperator), handlerMock);
      var queryModelVisitor = new TestableSqlPreparationQueryModelVisitor (_context, _stageMock, _generator, registry);
      var sqlStatementBuilder = queryModelVisitor.SqlStatementBuilder;

      handlerMock.Expect (
          mock =>
          mock.HandleResultOperator (
              Arg<ResultOperatorBase>.Matches (o => o == resultOperator),
              Arg<SqlStatementBuilder>.Matches (sb => sb == sqlStatementBuilder),
              Arg<UniqueIdentifierGenerator>.Matches (g => g == _generator),
              Arg<ISqlPreparationStage>.Matches (s => s == _stageMock),
              Arg<ISqlPreparationContext>.Matches (c => c != _context)));
      handlerMock.Replay();

      queryModelVisitor.VisitResultOperator (resultOperator, _queryModel, 0);

      handlerMock.VerifyAllExpectations();
    }
    public void VisitResultOperator_NoHandlerFound ()
    {
      var resultOperator = new TestChoiceResultOperator (false);
      var registry = new ResultOperatorHandlerRegistry ();
      var queryModelVisitor = new TestableSqlPreparationQueryModelVisitor (_context, _stageMock, _generator, registry);

      queryModelVisitor.VisitResultOperator (resultOperator, _queryModel, 0);
    }