public void ChangeToCreated_WhenObejectIsInClosedState_Throws(
            IEventStoreConnection connection,
            EventStoreConnectionState state)
        {
            state.ChangeToCreated(connection);
            state.ChangeToClosing();
            state.ChangeToClosed();

            Assert.Throws <InvalidOperationException>(() => state.ChangeToCreated(connection));
        }
        public void EnsureConnectionIsActive_WhenObjectIsInClosedState_Throws(
            IEventStoreConnection connection,
            EventStoreConnectionState state)
        {
            state.ChangeToCreated(connection);
            state.ChangeToClosing();
            state.ChangeToClosed();

            Assert.Throws <EventStreamConnectionWasClosedException>(
                () => state.EnsureConnectionIsActive());
        }
        public void ChangeToClosed_PropertiesTests(
            IEventStoreConnection connection,
            EventStoreConnectionState state)
        {
            state.ChangeToCreated(connection);
            state.ChangeToClosing();
            state.ChangeToClosed();

            Assert.False(state.IsActive);
            Assert.False(state.IsClosing);
            Assert.True(state.IsClosed);
        }
        public void ChangeToClosed_FiresConnectionClosedEvent(
            IEventStoreConnection connection,
            EventStoreConnectionState state)
        {
            var fired = false;

            state.ConnectionClosed += (sender, args) => fired = true;

            state.ChangeToCreated(connection);
            state.ChangeToClosing();
            state.ChangeToClosed();

            Assert.True(fired);
        }
 public void ChangeToClosed_WhenObejectIsNotInClosingState_Throws(
     IEventStoreConnection connection,
     EventStoreConnectionState state)
 {
     Assert.Throws <InvalidOperationException>(() => state.ChangeToClosed());
 }