private void ExpectRelationReadEvents(
            ClientTransaction clientTransaction,
            DomainObject domainObject,
            IRelationEndPointDefinition endPointDefinition,
            DomainObject[] relatedDomainObjects)
        {
            using (ListenerDynamicMock.GetMockRepository().Ordered())
            {
                ListenerDynamicMock.Expect(mock => mock.RelationReading(clientTransaction, domainObject, endPointDefinition, ValueAccess.Current));
                ListenerDynamicMock.Expect(
                    mock => mock.RelationRead(
                        Arg.Is(clientTransaction),
                        Arg.Is(domainObject),
                        Arg.Is(endPointDefinition),
                        Arg <ReadOnlyDomainObjectCollectionAdapter <DomainObject> > .List.Equivalent(relatedDomainObjects),
                        Arg.Is(ValueAccess.Current)));
            }

            using (ExtensionStrictMock.GetMockRepository().Ordered())
            {
                ExtensionStrictMock.Expect(mock => mock.RelationReading(clientTransaction, domainObject, endPointDefinition, ValueAccess.Current));
                ExtensionStrictMock.Expect(
                    mock => mock.RelationRead(
                        Arg.Is(clientTransaction),
                        Arg.Is(domainObject),
                        Arg.Is(endPointDefinition),
                        Arg <ReadOnlyDomainObjectCollectionAdapter <DomainObject> > .List.Equivalent(relatedDomainObjects),
                        Arg.Is(ValueAccess.Current)));
            }
        }
Exemplo n.º 2
0
        public void FilterQueryResult_RaisedInAllHierarchyLevels()
        {
            using (ExtensionStrictMock.GetMockRepository().Ordered())
            {
                ExtensionStrictMock
                .Expect(
                    mock => mock.FilterQueryResult(
                        Arg.Is(ReadOnlyRootTransaction),
                        Arg <QueryResult <DomainObject> > .Matches(qr => qr.ToArray().SequenceEqual(new[] { _order1 }))))
                .Return(new QueryResult <DomainObject> (_queryStub, new[] { _order3 }))
                .WhenCalled(mi => Assert.That(ReadOnlyRootTransaction.IsWriteable, Is.False));

                ExtensionStrictMock
                .Expect(
                    mock => mock.FilterQueryResult(
                        Arg.Is(ReadOnlyMiddleTransaction),
                        Arg <QueryResult <DomainObject> > .Matches(qr => qr.ToArray().SequenceEqual(new[] { _order3 }))))
                .Return(new QueryResult <DomainObject> (_queryStub, new[] { _order4 }))
                .WhenCalled(mi => Assert.That(ReadOnlyMiddleTransaction.IsWriteable, Is.False));

                ExtensionStrictMock
                .Expect(
                    mock => mock.FilterQueryResult(
                        Arg.Is(WriteableSubTransaction),
                        Arg <QueryResult <DomainObject> > .Matches(qr => qr.ToArray().SequenceEqual(new[] { _order4 }))))
                .Return(new QueryResult <DomainObject> (_queryStub, new[] { _order5 }))
                .WhenCalled(mi => Assert.That(WriteableSubTransaction.IsWriteable, Is.True));
            }

            var result = ExecuteInWriteableSubTransaction(() => QueryFactory.CreateLinqQuery <Order>().Where(obj => obj.ID == _order1.ID).ToList());

            ExtensionStrictMock.VerifyAllExpectations();
            Assert.That(result, Is.EqualTo(new[] { _order5 }));
        }
Exemplo n.º 3
0
        public void ObjectsLoading_Loaded_RaisedInAllHierarchyLevels()
        {
            using (ExtensionStrictMock.GetMockRepository().Ordered())
            {
                ExtensionStrictMock
                .Expect(
                    mock => mock.ObjectsLoading(
                        Arg.Is(ReadOnlyRootTransaction),
                        Arg <ReadOnlyCollection <ObjectID> > .List.Equal(new[] { _order.ID })))
                .WhenCalled(mi => Assert.That(ReadOnlyRootTransaction.IsWriteable, Is.False));
                ExtensionStrictMock
                .Expect(
                    mock => mock.ObjectsLoaded(
                        Arg.Is(ReadOnlyRootTransaction),
                        Arg <ReadOnlyCollection <DomainObject> > .List.Equal(new[] { _order })))
                .WhenCalled(mi => Assert.That(ReadOnlyRootTransaction.IsWriteable, Is.False));

                ExtensionStrictMock
                .Expect(
                    mock => mock.ObjectsLoading(
                        Arg.Is(ReadOnlyMiddleTransaction),
                        Arg <ReadOnlyCollection <ObjectID> > .List.Equal(new[] { _order.ID })))
                .WhenCalled(mi => Assert.That(ReadOnlyMiddleTransaction.IsWriteable, Is.False));
                ExtensionStrictMock
                .Expect(
                    mock => mock.ObjectsLoaded(
                        Arg.Is(ReadOnlyMiddleTransaction),
                        Arg <ReadOnlyCollection <DomainObject> > .List.Equal(new[] { _order })))
                .WhenCalled(mi => Assert.That(ReadOnlyMiddleTransaction.IsWriteable, Is.False));

                ExtensionStrictMock
                .Expect(
                    mock => mock.ObjectsLoading(
                        Arg.Is(WriteableSubTransaction),
                        Arg <ReadOnlyCollection <ObjectID> > .List.Equal(new[] { _order.ID })))
                .WhenCalled(mi => Assert.That(WriteableSubTransaction.IsWriteable, Is.True));
                ExtensionStrictMock
                .Expect(
                    mock => mock.ObjectsLoaded(
                        Arg.Is(WriteableSubTransaction),
                        Arg <ReadOnlyCollection <DomainObject> > .List.Equal(new[] { _order })))
                .WhenCalled(mi => Assert.That(WriteableSubTransaction.IsWriteable, Is.True));
            }

            ExecuteInWriteableSubTransaction(() => _order.EnsureDataAvailable());

            ExtensionStrictMock.VerifyAllExpectations();
        }
        private void ExpectRelationReadEvents(
            ClientTransaction clientTransaction,
            DomainObject domainObject,
            IRelationEndPointDefinition endPointDefinition,
            DomainObject relatedDomainObject)
        {
            using (ListenerDynamicMock.GetMockRepository().Ordered())
            {
                ListenerDynamicMock.Expect(mock => mock.RelationReading(clientTransaction, domainObject, endPointDefinition, ValueAccess.Current));
                ListenerDynamicMock.Expect(
                    mock => mock.RelationRead(clientTransaction, domainObject, endPointDefinition, relatedDomainObject, ValueAccess.Current));
            }

            using (ExtensionStrictMock.GetMockRepository().Ordered())
            {
                ExtensionStrictMock.Expect(mock => mock.RelationReading(clientTransaction, domainObject, endPointDefinition, ValueAccess.Current));
                ExtensionStrictMock.Expect(
                    mock => mock.RelationRead(clientTransaction, domainObject, endPointDefinition, relatedDomainObject, ValueAccess.Current));
            }
        }