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 })); }
public void RelationReadEvents_OnlyRaisedInWriteableSub_VirtualEndPoint_Many() { var endPointDefinition = GetEndPointDefinition(typeof(Order), "OrderItems"); ExpectRelationReadEvents(WriteableSubTransaction, _loadedOrder, endPointDefinition, new[] { _relatedOrderItem1, _relatedOrderItem2 }); ExecuteInWriteableSubTransaction(() => _loadedOrder.OrderItems.EnsureDataComplete()); AssertNoRelationReadEvents(ReadOnlyMiddleTransaction); AssertNoRelationReadEvents(ReadOnlyRootTransaction); ListenerDynamicMock.VerifyAllExpectations(); ExtensionStrictMock.VerifyAllExpectations(); }
public void RelationReadEvents_OnlyRaisedInWriteableSub_VirtualEndPoint_One() { var endPointDefinition = GetEndPointDefinition(typeof(Order), "OrderTicket"); ExpectRelationReadEvents(WriteableSubTransaction, _loadedOrder, endPointDefinition, _relatedOrderTicket); Dev.Null = ExecuteInWriteableSubTransaction(() => _loadedOrder.OrderTicket); AssertNoRelationReadEvents(ReadOnlyMiddleTransaction); AssertNoRelationReadEvents(ReadOnlyRootTransaction); ListenerDynamicMock.VerifyAllExpectations(); ExtensionStrictMock.VerifyAllExpectations(); }
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(); }