Exemple #1
0
        public override void SetUp()
        {
            base.SetUp();

            _dbCommandBuilderFactoryStrictMock = MockRepository.GenerateStrictMock <IDbCommandBuilderFactory>();

            _objectReaderFactoryStrictMock = MockRepository.GenerateStrictMock <IObjectReaderFactory>();
            _dataStoragePropertyDefinitionFactoryStrictMock = MockRepository.GenerateStrictMock <IDataStoragePropertyDefinitionFactory> ();

            _factory = new QueryCommandFactory(
                _objectReaderFactoryStrictMock,
                _dbCommandBuilderFactoryStrictMock,
                _dataStoragePropertyDefinitionFactoryStrictMock);

            _dataContainerReader1Stub = MockRepository.GenerateStub <IObjectReader <DataContainer> >();
            _resultRowReaderStub      = MockRepository.GenerateStub <IObjectReader <IQueryResultRow> >();

            _queryParameter1 = new QueryParameter("first", DomainObjectIDs.Order1);
            _queryParameter2 = new QueryParameter("second", DomainObjectIDs.Order3.Value);
            _queryParameter3 = new QueryParameter("third", DomainObjectIDs.Official1);
            var collection = new QueryParameterCollection {
                _queryParameter1, _queryParameter2, _queryParameter3
            };

            _queryStub = MockRepository.GenerateStub <IQuery>();
            _queryStub.Stub(stub => stub.Statement).Return("statement");
            _queryStub.Stub(stub => stub.Parameters).Return(new QueryParameterCollection(collection, true));

            _property1 = ObjectIDStoragePropertyDefinitionObjectMother.Create("Test");
            _property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty();
            _property3 = SerializedObjectIDStoragePropertyDefinitionObjectMother.Create("Test");
        }
Exemple #2
0
        public void ResolveIDPropertyViaForeignKey_WithFullObjectID_ResolvesToCompound()
        {
            var propertyDefinition      = CreatePropertyDefinitionAndAssociateWithClass(_classDefinition, "Customer", "Customer");
            var objectIDStorageProperty = ObjectIDStoragePropertyDefinitionObjectMother.Create(
                "CustomerID",
                "CustomerClassID",
                StorageTypeInformationObjectMother.CreateUniqueIdentifierStorageTypeInformation(),
                StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation());

            var foreignKeyEndPointDefinition = new RelationEndPointDefinition(propertyDefinition, false);

            _rdbmsPersistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(foreignKeyEndPointDefinition.PropertyDefinition))
            .Return(objectIDStorageProperty);

            var originatingEntity = CreateEntityDefinition(typeof(Order), "o");

            var result = _storageSpecificExpressionResolver.ResolveIDPropertyViaForeignKey(originatingEntity, foreignKeyEndPointDefinition);

            var expected = Expression.New(
                MemberInfoFromExpressionUtility.GetConstructor(() => new ObjectID("classID", "value")),
                new[]
            {
                new NamedExpression("ClassID", originatingEntity.GetColumn(typeof(string), "CustomerClassID", false)),
                new NamedExpression("Value", Expression.Convert(originatingEntity.GetColumn(typeof(Guid), "CustomerID", false), typeof(object)))
            },
                new[] { typeof(ObjectID).GetProperty("ClassID"), typeof(ObjectID).GetProperty("Value") });

            SqlExpressionTreeComparer.CheckAreEqualTrees(expected, result);
        }