public void Serialization()
        {
            var innerEndPoint = new SerializableCollectionEndPointFake();
            var listener      = new SerializableVirtualEndPointStateUpdateListenerFake();
            var instance      = new StateUpdateRaisingCollectionEndPointDecorator(innerEndPoint, listener);

            var deserializedInstance = FlattenedSerializer.SerializeAndDeserialize(instance);

            Assert.That(deserializedInstance.InnerEndPoint, Is.Not.Null);
            Assert.That(deserializedInstance.Listener, Is.Not.Null);
        }
        public override void SetUp()
        {
            base.SetUp();

            _endPointID        = RelationEndPointID.Create(DomainObjectIDs.Order1, typeof(Order), "OrderItems");
            _listenerMock      = MockRepository.GenerateStrictMock <IVirtualEndPointStateUpdateListener> ();
            _innerEndPointMock = MockRepository.GenerateStrictMock <ICollectionEndPoint>();
            _innerEndPointMock.Stub(stub => stub.HasChangedFast).Return(false);
            _innerEndPointMock.Stub(stub => stub.ID).Return(_endPointID);

            _decorator           = new StateUpdateRaisingCollectionEndPointDecorator(_innerEndPointMock, _listenerMock);
            _decoratorTestHelper = new DecoratorTestHelper <ICollectionEndPoint> (_decorator, _innerEndPointMock);
        }
        public void SetDataFromSubTransaction_UnwrapsSourceEndPoint()
        {
            var sourceInnerEndPoint = MockRepository.GenerateStub <ICollectionEndPoint> ();
            var sourceEndPoint      = new StateUpdateRaisingCollectionEndPointDecorator(sourceInnerEndPoint, _listenerMock);

            _listenerMock.Expect(mock => mock.VirtualEndPointStateUpdated(_endPointID, null));
            _listenerMock.Replay();

            _innerEndPointMock.BackToRecord();
            _innerEndPointMock.Stub(stub => stub.ID).Return(_endPointID);
            _innerEndPointMock.Stub(stub => stub.HasChangedFast).Return(null);
            _innerEndPointMock
            .Expect(ep => ep.SetDataFromSubTransaction(sourceInnerEndPoint))
            .WhenCalled(mi => _listenerMock.AssertWasNotCalled(mock => mock.VirtualEndPointStateUpdated(Arg <RelationEndPointID> .Is.Anything, Arg <bool?> .Is.Anything)));
            _innerEndPointMock.Replay();

            _decorator.SetDataFromSubTransaction(sourceEndPoint);

            _innerEndPointMock.VerifyAllExpectations();
            _listenerMock.AssertWasCalled(mock => mock.VirtualEndPointStateUpdated(_endPointID, null));
        }
        public void SetDataFromSubTransaction_WithException()
        {
            var sourceInnerEndPoint = MockRepository.GenerateStub <ICollectionEndPoint> ();
            var sourceEndPoint      = new StateUpdateRaisingCollectionEndPointDecorator(sourceInnerEndPoint, _listenerMock);

            _listenerMock.Expect(mock => mock.VirtualEndPointStateUpdated(_endPointID, null));
            _listenerMock.Replay();

            var exception = new Exception();

            _innerEndPointMock.BackToRecord();
            _innerEndPointMock.Stub(stub => stub.ID).Return(_endPointID);
            _innerEndPointMock.Stub(stub => stub.HasChangedFast).Return(null);
            _innerEndPointMock
            .Expect(ep => ep.SetDataFromSubTransaction(sourceInnerEndPoint))
            .Throw(exception);
            _innerEndPointMock.Replay();

            Assert.That(() => _decorator.SetDataFromSubTransaction(sourceEndPoint), Throws.Exception.SameAs(exception));

            _innerEndPointMock.VerifyAllExpectations();
            _listenerMock.VerifyAllExpectations();
        }