public new void ToString()
        {
            var joinInfo = SqlStatementModelObjectMother.CreateUnresolvedJoinInfo_KitchenCook();
            var result   = joinInfo.ToString();

            Assert.That(result, Is.EqualTo("Kitchen.Cook"));
        }
Example #2
0
        public void ToString_SqlJoinedTableWithUnresolvedJoinInfo()
        {
            var sqlTable   = new SqlJoinedTable(SqlStatementModelObjectMother.CreateUnresolvedJoinInfo_KitchenCook(), JoinSemantics.Left);
            var expression = new SqlTableReferenceExpression(sqlTable);
            var result     = expression.ToString();

            Assert.That(result, Is.EqualTo("TABLE-REF(UnresolvedJoinInfo(Cook))"));
        }
Example #3
0
 public void SetUp()
 {
     _resolverMock             = MockRepository.GenerateStrictMock <IMappingResolver>();
     _unresolvedJoinInfo       = SqlStatementModelObjectMother.CreateUnresolvedJoinInfo_KitchenCook();
     _generator                = new UniqueIdentifierGenerator();
     _stageMock                = MockRepository.GenerateStrictMock <IMappingResolutionStage> ();
     _mappingResolutionContext = new MappingResolutionContext();
 }
        public void Accept()
        {
            var joinInfo = SqlStatementModelObjectMother.CreateUnresolvedJoinInfo_KitchenCook();

            var joinInfoVisitorMock = MockRepository.GenerateMock <IJoinInfoVisitor>();

            joinInfoVisitorMock.Expect(mock => mock.VisitUnresolvedJoinInfo(joinInfo));

            joinInfoVisitorMock.Replay();

            joinInfo.Accept(joinInfoVisitorMock);
            joinInfoVisitorMock.VerifyAllExpectations();
        }
Example #5
0
        public void ResolveJoinedTable()
        {
            var joinInfo    = SqlStatementModelObjectMother.CreateUnresolvedJoinInfo_KitchenCook();
            var joinedTable = new SqlJoinedTable(joinInfo, JoinSemantics.Left);

            var fakeJoinInfo = SqlStatementModelObjectMother.CreateResolvedJoinInfo();

            _stageMock
            .Expect(mock => mock.ResolveJoinInfo(joinInfo, _mappingResolutionContext))
            .Return(fakeJoinInfo);
            _stageMock.Replay();

            _visitor.ResolveJoinedTable(joinedTable);

            Assert.That(joinedTable.JoinInfo, Is.SameAs(fakeJoinInfo));
        }
        public void ResolveJoinInfo()
        {
            var joinInfo = SqlStatementModelObjectMother.CreateUnresolvedJoinInfo_KitchenCook();

            var fakeResolvedJoinInfo = SqlStatementModelObjectMother.CreateResolvedJoinInfo(typeof(Cook));

            _resolverMock
            .Expect(mock => mock.ResolveJoinInfo(joinInfo, _uniqueIdentifierGenerator))
            .Return(fakeResolvedJoinInfo);
            _resolverMock.Replay();

            var result = _stage.ResolveJoinInfo(joinInfo, _mappingResolutionContext);

            _resolverMock.VerifyAllExpectations();
            Assert.That(result, Is.SameAs(fakeResolvedJoinInfo));
        }
        public void ResolveEntityRefMemberExpression()
        {
            var kitchenCookMember         = typeof(Kitchen).GetProperty("Cook");
            var entityExpression          = SqlStatementModelObjectMother.CreateSqlEntityDefinitionExpression(typeof(Kitchen));
            var entityRefMemberExpression = new SqlEntityRefMemberExpression(entityExpression, kitchenCookMember);
            var unresolvedJoinInfo        = SqlStatementModelObjectMother.CreateUnresolvedJoinInfo_KitchenCook();
            var fakeJoinInfo = SqlStatementModelObjectMother.CreateResolvedJoinInfo(typeof(Cook));

            _mappingResolutionContext.AddSqlEntityMapping(entityExpression, SqlStatementModelObjectMother.CreateSqlTable(typeof(Cook)));

            var fakeEntityExpression = SqlStatementModelObjectMother.CreateSqlEntityDefinitionExpression(typeof(Cook));

            _resolverMock
            .Expect(
                mock =>
                mock.ResolveJoinInfo(
                    Arg <UnresolvedJoinInfo> .Matches(joinInfo => joinInfo.MemberInfo == kitchenCookMember), Arg <UniqueIdentifierGenerator> .Is.Anything))
            .Return(fakeJoinInfo);

            _resolverMock
            .Expect(
                mock =>
                mock.ResolveSimpleTableInfo(
                    Arg <IResolvedTableInfo> .Is.Anything,
                    Arg <UniqueIdentifierGenerator> .Is.Anything))
            .Return(fakeEntityExpression);

            var result = _stage.ResolveEntityRefMemberExpression(entityRefMemberExpression, unresolvedJoinInfo, _mappingResolutionContext);

            _resolverMock.VerifyAllExpectations();

            Assert.That(result, Is.SameAs(fakeEntityExpression));
            var sqlTable = _mappingResolutionContext.GetSqlTableForEntityExpression(entityRefMemberExpression.OriginatingEntity);

            Assert.That(sqlTable.GetJoin(kitchenCookMember), Is.Not.Null);
            Assert.That(sqlTable.GetJoin(kitchenCookMember).JoinInfo, Is.SameAs(fakeJoinInfo));
        }
        public void GetResolvedTableInfo_Throws()
        {
            var joinInfo = SqlStatementModelObjectMother.CreateUnresolvedJoinInfo_KitchenCook();

            joinInfo.GetResolvedJoinInfo();
        }