public void GenerateSql_WithUnresolvedTableInfo_RaisesException()
        {
            var sqlTable = SqlStatementModelObjectMother.CreateSqlTable_WithUnresolvedTableInfo();

            Assert.That(
                () => SqlTableAndJoinTextGenerator.GenerateSql(sqlTable, _commandBuilder, _stageMock, false),
                Throws.TypeOf <InvalidOperationException>().With.Message.EqualTo("UnresolvedTableInfo is not valid at this point."));
        }
        public void GenerateSql_ForTable()
        {
            var sqlTable = SqlStatementModelObjectMother.CreateSqlTable_WithUnresolvedTableInfo();

            sqlTable.TableInfo = new ResolvedSimpleTableInfo(typeof(int), "Table", "t");
            SqlTableAndJoinTextGenerator.GenerateSql(sqlTable, _commandBuilder, _stageMock, true);

            Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("[Table] AS [t]"));
        }
        public void ResolveSqlStatement()
        {
            var sqlTable = SqlStatementModelObjectMother.CreateSqlTable_WithUnresolvedTableInfo(typeof(Cook));
            var tableReferenceExpression = new SqlTableReferenceExpression(new SqlTable(_fakeResolvedSimpleTableInfo, JoinSemantics.Inner));
            var sqlStatement             = SqlStatementModelObjectMother.CreateSqlStatement(tableReferenceExpression, new[] { sqlTable });
            var fakeEntityExpression     = SqlStatementModelObjectMother.CreateSqlEntityDefinitionExpression(typeof(Cook));

            _resolverMock
            .Expect(mock => mock.ResolveTableInfo((UnresolvedTableInfo)((SqlTable)sqlStatement.SqlTables[0]).TableInfo, _uniqueIdentifierGenerator))
            .Return(_fakeResolvedSimpleTableInfo);
            _resolverMock
            .Expect(mock => mock.ResolveSimpleTableInfo(tableReferenceExpression.SqlTable.GetResolvedTableInfo(), _uniqueIdentifierGenerator))
            .Return(fakeEntityExpression);
            _resolverMock.Replay();

            var newSqlStatment = _stage.ResolveSqlStatement(sqlStatement, _mappingResolutionContext);

            _resolverMock.VerifyAllExpectations();
            Assert.That(((SqlTable)newSqlStatment.SqlTables[0]).TableInfo, Is.SameAs(_fakeResolvedSimpleTableInfo));
            Assert.That(newSqlStatment.SelectProjection, Is.SameAs(fakeEntityExpression));
        }
Beispiel #4
0
        public void Initialize()
        {
            var sqlTable = SqlStatementModelObjectMother.CreateSqlTable_WithUnresolvedTableInfo();

            Assert.That(new SqlTableReferenceExpression(sqlTable).Type, Is.EqualTo(sqlTable.TableInfo.ItemType));
        }