public override void SetUp() { base.SetUp(); _owningOrder = DomainObjectIDs.Order1.GetObject <Order> (); _endPointID = RelationEndPointID.Resolve(_owningOrder, o => o.OrderItems); _collectionEndPointMock = MockRepository.GenerateStrictMock <ICollectionEndPoint>(); StubCollectionEndPoint(_collectionEndPointMock, TestableClientTransaction, _owningOrder); _virtualEndPointProviderStub = MockRepository.GenerateStub <IVirtualEndPointProvider> (); _virtualEndPointProviderStub .Stub(stub => stub.GetOrCreateVirtualEndPoint(_endPointID)) .Return(_collectionEndPointMock); _endPointDataStub = MockRepository.GenerateStub <IDomainObjectCollectionData>(); _endPointDataDecorator = new ReadOnlyCollectionDataDecorator(_endPointDataStub); _commandStub = MockRepository.GenerateStub <IDataManagementCommand>(); _nestedCommandMock = MockRepository.GenerateMock <IDataManagementCommand> (); _nestedCommandMock.Stub(stub => stub.GetAllExceptions()).Return(new Exception[0]); _expandedCommandFake = new ExpandedCommand(_nestedCommandMock); _delegatingData = new EndPointDelegatingCollectionData(_endPointID, _virtualEndPointProviderStub); _orderItem1 = DomainObjectIDs.OrderItem1.GetObject <OrderItem>(); _orderItem2 = DomainObjectIDs.OrderItem2.GetObject <OrderItem>(); ClientTransactionScope.EnterNullScope(); // no active transaction }
/// <summary> /// Raises all events and performs the action of the given <see cref="IDataManagementCommand"/>. /// The order of events is as follows: <see cref="IDataManagementCommand.Begin"/>, /// <see cref="IDataManagementCommand.Begin"/>, <see cref="IDataManagementCommand.Perform"/>, /// <see cref="IDataManagementCommand.End"/>, <see cref="IDataManagementCommand.End"/>. /// </summary> /// <param name="command">The command to be executed.</param> public static void NotifyAndPerform(this IDataManagementCommand command) { ArgumentUtility.CheckNotNull("command", command); command.Begin(); command.Perform(); command.End(); }
/// <summary> /// Ensures the given command can be executed (i.e., it has no associated exceptions). If it can't, this method throws the first of the command's /// associated exceptions /// </summary> public static void EnsureCanExecute(this IDataManagementCommand command) { var exception = command.GetAllExceptions().FirstOrDefault(); if (exception != null) { throw exception; } }
protected override IDataManagementCommand Decorate(IDataManagementCommand decoratedCommand) { ArgumentUtility.CheckNotNull("decoratedCommand", decoratedCommand); return(new RealObjectEndPointRegistrationCommandDecorator( decoratedCommand, _realObjectEndPoint, _oldRelatedEndPoint, _newRelatedEndPoint)); }
public UnloadCommand( ICollection <DomainObject> domainObjects, IDataManagementCommand unloadDataCommand, IClientTransactionEventSink transactionEventSink) { ArgumentUtility.CheckNotNullOrEmpty("domainObjects", domainObjects); ArgumentUtility.CheckNotNull("unloadDataCommand", unloadDataCommand); ArgumentUtility.CheckNotNull("transactionEventSink", transactionEventSink); _domainObjects = domainObjects.ToArray(); _unloadDataCommand = unloadDataCommand; _transactionEventSink = transactionEventSink; }
private IDataManagementCommand UnwrapCommand(IDataManagementCommand c) { if (c is RealObjectEndPointRegistrationCommandDecorator) { return(((RealObjectEndPointRegistrationCommandDecorator)c).DecoratedCommand); } else if (c is VirtualEndPointStateUpdatedRaisingCommandDecorator) { return(((VirtualEndPointStateUpdatedRaisingCommandDecorator)c).DecoratedCommand); } else { return(c); } }
public VirtualEndPointStateUpdatedRaisingCommandDecorator( IDataManagementCommand decoratedCommand, RelationEndPointID modifiedEndPointID, IVirtualEndPointStateUpdateListener listener, Func <bool?> changeStateProvider) : base(decoratedCommand) { ArgumentUtility.CheckNotNull("modifiedEndPointID", modifiedEndPointID); ArgumentUtility.CheckNotNull("listener", listener); ArgumentUtility.CheckNotNull("changeStateProvider", changeStateProvider); _modifiedEndPointID = modifiedEndPointID; _listener = listener; _changeStateProvider = changeStateProvider; }
public RealObjectEndPointRegistrationCommandDecorator( IDataManagementCommand decoratedCommand, IRealObjectEndPoint realObjectEndPoint, IVirtualEndPoint oldRelatedEndPoint, IVirtualEndPoint newRelatedEndPoint) : base(decoratedCommand) { ArgumentUtility.CheckNotNull("realObjectEndPoint", realObjectEndPoint); ArgumentUtility.CheckNotNull("oldRelatedEndPoint", oldRelatedEndPoint); ArgumentUtility.CheckNotNull("newRelatedEndPoint", newRelatedEndPoint); _realObjectEndPoint = realObjectEndPoint; _oldRelatedEndPoint = oldRelatedEndPoint; _newRelatedEndPoint = newRelatedEndPoint; }
public override void SetUp() { base.SetUp(); _mockRepository = new MockRepository(); _decoratedCommandMock = _mockRepository.StrictMock <IDataManagementCommand> (); _modifiedEndPointID = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderItems"); _stateUpdateListenerMock = _mockRepository.StrictMock <IVirtualEndPointStateUpdateListener> (); _fakeChangeState = null; _commandDecorator = new VirtualEndPointStateUpdatedRaisingCommandDecorator( _decoratedCommandMock, _modifiedEndPointID, _stateUpdateListenerMock, () => _fakeChangeState); _decoratorTestHelper = new DecoratorTestHelper <IDataManagementCommand> (_commandDecorator, _decoratedCommandMock); }
public void SetUp() { _mockRepository = new MockRepository(); _decoratedCommandMock = _mockRepository.StrictMock <IDataManagementCommand> (); _realObjectEndPointStub = _mockRepository.Stub <IRealObjectEndPoint> (); _oldRelatedEndPointMock = _mockRepository.StrictMock <IVirtualEndPoint> (); _newRelatedEndPointMock = _mockRepository.StrictMock <IVirtualEndPoint> (); _decorator = new RealObjectEndPointRegistrationCommandDecorator( _decoratedCommandMock, _realObjectEndPointStub, _oldRelatedEndPointMock, _newRelatedEndPointMock); _exception1 = new Exception("1"); _exception2 = new Exception("2"); }
public override void SetUp() { base.SetUp(); _leafRootTransaction = ClientTransaction.CreateRootTransaction(); _rootTransactionWithSub = ClientTransaction.CreateRootTransaction(); _leafSubTransaction = _rootTransactionWithSub.CreateSubTransaction(); _readOnlyTransaction = new TestableClientTransaction(); ClientTransactionTestHelper.SetIsWriteable(_readOnlyTransaction, false); _mockRepository = new MockRepository(); _commandFactoryMock = _mockRepository.StrictMock <ICommandFactory>(); _commandMock1 = _mockRepository.StrictMock <IDataManagementCommand> (); _commandMock2 = _mockRepository.StrictMock <IDataManagementCommand> (); _executor = new TransactionHierarchyCommandExecutor(_commandFactoryMock.Create); }
public override void SetUp() { base.SetUp(); _mockRepository = new MockRepository(); _domainObject1 = DomainObjectMother.CreateFakeObject <Order>(); _domainObject2 = DomainObjectMother.CreateFakeObject <Order> (); _transactionEventSinkWithMock = MockRepository.GenerateStrictMock <IClientTransactionEventSink>(); _unloadDataCommandMock = _mockRepository.StrictMock <IDataManagementCommand>(); _unloadCommand = new UnloadCommand( new[] { _domainObject1, _domainObject2 }, _unloadDataCommandMock, _transactionEventSinkWithMock); _exception1 = new Exception("1"); _exception2 = new Exception("2"); }
public void SetUp() { _mockRepository = new MockRepository(); _commandMock1 = _mockRepository.StrictMock <IDataManagementCommand> (); _commandMock1.Stub(stub => stub.GetAllExceptions()).Return(new Exception[0]); _commandMock2 = _mockRepository.StrictMock <IDataManagementCommand> (); _commandMock2.Stub(stub => stub.GetAllExceptions()).Return(new Exception[0]); _commandMock3 = _mockRepository.StrictMock <IDataManagementCommand> (); _commandMock3.Stub(stub => stub.GetAllExceptions()).Return(new Exception[0]); _nonExecutableCommandMock1 = _mockRepository.StrictMock <IDataManagementCommand> (); _nonExecutableCommandMock2 = _mockRepository.StrictMock <IDataManagementCommand> (); _exception1 = new Exception("1"); _exception2 = new Exception("2"); _exception3 = new Exception("3"); _nonExecutableCommandMock1.Stub(stub => stub.GetAllExceptions()).Return(new[] { _exception1, _exception2 }); _nonExecutableCommandMock2.Stub(stub => stub.GetAllExceptions()).Return(new[] { _exception3 }); }
protected override IDataManagementCommand Decorate(IDataManagementCommand decoratedCommand) { ArgumentUtility.CheckNotNull("decoratedCommand", decoratedCommand); return(new UnlockingCommandDecorator(decoratedCommand, _transactionToBeUnlocked)); }
public UnlockingCommandDecorator(IDataManagementCommand decoratedCommand, ClientTransaction transactionToBeUnlocked) : base(decoratedCommand) { _transactionToBeUnlocked = transactionToBeUnlocked; }
protected override IDataManagementCommand Decorate(IDataManagementCommand decoratedCommand) { ArgumentUtility.CheckNotNull("decoratedCommand", decoratedCommand); return(new VirtualEndPointStateUpdatedRaisingCommandDecorator(decoratedCommand, _modifiedEndPointID, _listener, _changeStateProvider)); }
public void SetUp() { _commandMock = MockRepository.GenerateStrictMock <IDataManagementCommand> (); }
/// <summary> /// Gets a value indicating whether this command can be executed (i.e., it has no associated exceptions). /// </summary> /// <value> /// <see langword="true"/> if this instance command can be execute; otherwise, <see langword="false"/>. /// </value> public static bool CanExecute(this IDataManagementCommand command) { return(!command.GetAllExceptions().Any()); }
private IDataManagementCommand CreateStateUpdateRaisingCommandDecorator (IDataManagementCommand command) { return new VirtualEndPointStateUpdatedRaisingCommandDecorator (command, _innerEndPoint.ID, _listener, () => _innerEndPoint.HasChangedFast); }
protected abstract IDataManagementCommand Decorate(IDataManagementCommand decoratedCommand);
protected DataManagementCommandDecoratorBase(IDataManagementCommand decoratedCommand) { ArgumentUtility.CheckNotNull("decoratedCommand", decoratedCommand); _decoratedCommand = decoratedCommand; }
public TestableDataManagementCommandDecoratorBase(IDataManagementCommand decoratedCommand) : base(decoratedCommand) { }
protected override IDataManagementCommand Decorate(IDataManagementCommand decoratedCommand) { return(new TestableDataManagementCommandDecoratorBase(decoratedCommand)); }
public void SetUp() { _decoratedCommandMock = MockRepository.GenerateStrictMock <IDataManagementCommand>(); _decorator = new TestableDataManagementCommandDecoratorBase(_decoratedCommandMock); }