public void SetUp()
        {
            _stageMock = MockRepository.GenerateStrictMock <ISqlPreparationStage>();
            _generator = new UniqueIdentifierGenerator();
            _context   = SqlStatementModelObjectMother.CreateSqlPreparationContext();
            _methodCallTransformerProvider = CompoundMethodCallTransformerProvider.CreateDefault();

            _someOrderingExtractionPolicy = Some.Item(
                OrderingExtractionPolicy.ExtractOrderingsIntoProjection,
                OrderingExtractionPolicy.DoNotExtractOrderings);

            _tableGenerator = info => new SqlTable(info, JoinSemantics.Inner);
        }
コード例 #2
0
        public void MoveCurrentStatementToSqlTable()
        {
            var originalStatement = _statementBuilder.GetSqlStatement();

            var fakeFromExpressionInfo = CreateFakeFromExpressionInfo(new Ordering[0]);
            Func <ITableInfo, SqlTable> tableGenerator = info => new SqlTable(info, JoinSemantics.Inner);

            var someOrderingExtractionPolicy = Some.Item(
                OrderingExtractionPolicy.DoNotExtractOrderings,
                OrderingExtractionPolicy.ExtractOrderingsIntoProjection);

            _stageMock
            .Expect(mock => mock.PrepareFromExpression(
                        Arg <SqlSubStatementExpression> .Is.TypeOf,
                        Arg.Is(_context),
                        Arg.Is(tableGenerator),
                        Arg.Is(someOrderingExtractionPolicy)))
            .Return(fakeFromExpressionInfo)
            .WhenCalled(mi =>
            {
                var sqlStatement = ((SqlSubStatementExpression)mi.Arguments[0]).SqlStatement;
                SqlExpressionTreeComparer.CheckAreEqualTrees(new NamedExpression(null, originalStatement.SelectProjection), sqlStatement.SelectProjection);

                Assert.That(sqlStatement.DataInfo, Is.SameAs(originalStatement.DataInfo));
                Assert.That(sqlStatement.WhereCondition, Is.SameAs(originalStatement.WhereCondition));
            });
            _stageMock.Replay();

            _handler.MoveCurrentStatementToSqlTable(_statementBuilder, _context, tableGenerator, _stageMock, someOrderingExtractionPolicy);

            _stageMock.VerifyAllExpectations();

            Assert.That(_statementBuilder.DataInfo, Is.SameAs(originalStatement.DataInfo));
            Assert.That(_statementBuilder.SqlTables[0], Is.SameAs(fakeFromExpressionInfo.SqlTable));
            Assert.That(_statementBuilder.SelectProjection, Is.SameAs(fakeFromExpressionInfo.ItemSelector));

            var mappedItemExpression = _context.GetExpressionMapping(((StreamedSequenceInfo)originalStatement.DataInfo).ItemExpression);

            Assert.That(mappedItemExpression, Is.Not.Null);
            Assert.That(mappedItemExpression, Is.SameAs(fakeFromExpressionInfo.ItemSelector));
        }
コード例 #3
0
        public void SetUp()
        {
            _stageMock             = MockRepository.GenerateStrictMock <ISqlGenerationStage> ();
            _commandBuilder        = new SqlCommandBuilder();
            _someSetOperationsMode = Some.Item(SetOperationsMode.StatementIsSetCombined, SetOperationsMode.StatementIsNotSetCombined);
            _visitor = CreateVisitor(_someSetOperationsMode);

            _namedIntExpression = new NamedExpression("test", Expression.Constant(0));
            var nameColumnExpression = new SqlColumnDefinitionExpression(typeof(string), "c", "Name", false);

            _namedNameColumnExpression = new NamedExpression("SomeName", nameColumnExpression);
            _entityExpression          = new SqlEntityDefinitionExpression(
                typeof(Cook),
                "c",
                "test",
                e => e,
                new SqlColumnDefinitionExpression(typeof(int), "c", "ID", true),
                nameColumnExpression,
                new SqlColumnDefinitionExpression(typeof(string), "c", "FirstName", false)
                );
        }