|
| 1 | +using ReactiveDomain.Util; |
| 2 | +using System; |
| 3 | + |
| 4 | +namespace ReactiveDomain.Testing |
| 5 | +{ |
| 6 | + /// <summary> |
| 7 | + /// An empty connection that implements <see cref="IStreamStoreConnection"/>. |
| 8 | + /// </summary> |
| 9 | + public class NullConnection : IStreamStoreConnection |
| 10 | + { |
| 11 | + /// <summary> |
| 12 | + /// The name of the connection. |
| 13 | + /// </summary> |
| 14 | + public string ConnectionName => "NullConnection"; |
| 15 | + |
| 16 | + /// <summary> |
| 17 | + /// Drops the events and returns a write result at the default version. |
| 18 | + /// </summary> |
| 19 | + /// <param name="stream">This parameter is ignored.</param> |
| 20 | + /// <param name="expectedVersion">This parameter is ignored.</param> |
| 21 | + /// <param name="credentials">This parameter is ignored.</param> |
| 22 | + /// <param name="events">This parameter is ignored.</param> |
| 23 | + /// <returns>A <see cref="WriteResult"/> at the default version.</returns> |
| 24 | + public WriteResult AppendToStream(string stream, long expectedVersion, UserCredentials credentials = null, params EventData[] events) |
| 25 | + { |
| 26 | + return new WriteResult(0); |
| 27 | + } |
| 28 | + |
| 29 | + /// <summary> |
| 30 | + /// Does nothing. Required for implementation of <see cref="IStreamStoreConnection"/>. |
| 31 | + /// </summary> |
| 32 | + public void Close() { } |
| 33 | + |
| 34 | + /// <summary> |
| 35 | + /// Does nothing. Required for implementation of <see cref="IStreamStoreConnection"/>. |
| 36 | + /// </summary> |
| 37 | + public void Connect() { } |
| 38 | + |
| 39 | + /// <summary> |
| 40 | + /// Does nothing. Required for implementation of <see cref="IStreamStoreConnection"/>. |
| 41 | + /// </summary> |
| 42 | + /// <param name="stream">This parameter is ignored.</param> |
| 43 | + /// <param name="expectedVersion">This parameter is ignored.</param> |
| 44 | + /// <param name="credentials">This parameter is ignored.</param> |
| 45 | + public void DeleteStream(string stream, long expectedVersion, UserCredentials credentials = null) |
| 46 | + { |
| 47 | + } |
| 48 | + |
| 49 | + /// <summary> |
| 50 | + /// Cleans up resources. |
| 51 | + /// </summary> |
| 52 | + public void Dispose() |
| 53 | + { |
| 54 | + } |
| 55 | + |
| 56 | + /// <summary> |
| 57 | + /// Does nothing. Required for implementation of <see cref="IStreamStoreConnection"/>. |
| 58 | + /// </summary> |
| 59 | + /// <param name="stream">This parameter is ignored.</param> |
| 60 | + /// <param name="expectedVersion">This parameter is ignored.</param> |
| 61 | + /// <param name="credentials">This parameter is ignored.</param> |
| 62 | + public void HardDeleteStream(string stream, long expectedVersion, UserCredentials credentials = null) |
| 63 | + { |
| 64 | + } |
| 65 | + |
| 66 | + /// <summary> |
| 67 | + /// Gets an empty stream slice. |
| 68 | + /// </summary> |
| 69 | + /// <param name="stream">This parameter is ignored.</param> |
| 70 | + /// <param name="start">This parameter is ignored.</param> |
| 71 | + /// <param name="count">This parameter is ignored.</param> |
| 72 | + /// <param name="credentials">This parameter is ignored.</param> |
| 73 | + /// <returns>An empty <see cref="StreamEventsSlice"/>.</returns> |
| 74 | + public StreamEventsSlice ReadStreamBackward(string stream, long start, long count, UserCredentials credentials = null) |
| 75 | + { |
| 76 | + return new StreamEventsSlice(stream, 0, ReadDirection.Backward, Array.Empty<RecordedEvent>(), 0, 0, true); |
| 77 | + } |
| 78 | + |
| 79 | + /// <summary> |
| 80 | + /// Gets an empty stream slice. |
| 81 | + /// </summary> |
| 82 | + /// <param name="stream">This parameter is ignored.</param> |
| 83 | + /// <param name="start">This parameter is ignored.</param> |
| 84 | + /// <param name="count">This parameter is ignored.</param> |
| 85 | + /// <param name="credentials">This parameter is ignored.</param> |
| 86 | + /// <returns>An empty <see cref="StreamEventsSlice"/>.</returns> |
| 87 | + public StreamEventsSlice ReadStreamForward(string stream, long start, long count, UserCredentials credentials = null) |
| 88 | + { |
| 89 | + return new StreamEventsSlice(stream, 0, ReadDirection.Forward, Array.Empty<RecordedEvent>(), 0, 0, true); |
| 90 | + } |
| 91 | + |
| 92 | + /// <summary> |
| 93 | + /// Does nothing. Required for implementation of <see cref="IStreamStoreConnection"/>. |
| 94 | + /// </summary> |
| 95 | + /// <param name="eventAppeared">This parameter is ignored.</param> |
| 96 | + /// <param name="subscriptionDropped">This parameter is ignored.</param> |
| 97 | + /// <param name="credentials">This parameter is ignored.</param> |
| 98 | + /// <param name="resolveLinkTos">This parameter is ignored.</param> |
| 99 | + /// <returns>This connection.</returns> |
| 100 | + public IDisposable SubscribeToAll(Action<RecordedEvent> eventAppeared, Action<SubscriptionDropReason, Exception> subscriptionDropped = null, UserCredentials credentials = null, bool resolveLinkTos = true) |
| 101 | + { |
| 102 | + return this; |
| 103 | + } |
| 104 | + |
| 105 | + /// <summary> |
| 106 | + /// Does nothing. Required for implementation of <see cref="IStreamStoreConnection"/>. |
| 107 | + /// </summary> |
| 108 | + /// <param name="from">This parameter is ignored.</param> |
| 109 | + /// <param name="eventAppeared">This parameter is ignored.</param> |
| 110 | + /// <param name="settings">This parameter is ignored.</param> |
| 111 | + /// <param name="liveProcessingStarted">This parameter is ignored.</param> |
| 112 | + /// <param name="subscriptionDropped">This parameter is ignored.</param> |
| 113 | + /// <param name="credentials">This parameter is ignored.</param> |
| 114 | + /// <param name="resolveLinkTos">This parameter is ignored.</param> |
| 115 | + /// <returns>This connection.</returns> |
| 116 | + public IDisposable SubscribeToAllFrom(Position from, Action<RecordedEvent> eventAppeared, CatchUpSubscriptionSettings settings = null, Action liveProcessingStarted = null, Action<SubscriptionDropReason, Exception> subscriptionDropped = null, UserCredentials credentials = null, bool resolveLinkTos = true) |
| 117 | + { |
| 118 | + return this; |
| 119 | + } |
| 120 | + |
| 121 | + /// <summary> |
| 122 | + /// Does nothing. Required for implementation of <see cref="IStreamStoreConnection"/>. |
| 123 | + /// </summary> |
| 124 | + /// <param name="stream">This parameter is ignored.</param> |
| 125 | + /// <param name="eventAppeared">This parameter is ignored.</param> |
| 126 | + /// <param name="subscriptionDropped">This parameter is ignored.</param> |
| 127 | + /// <param name="credentials">This parameter is ignored.</param> |
| 128 | + /// <returns>This connection.</returns> |
| 129 | + public IDisposable SubscribeToStream(string stream, Action<RecordedEvent> eventAppeared, Action<SubscriptionDropReason, Exception> subscriptionDropped = null, UserCredentials credentials = null) |
| 130 | + { |
| 131 | + return this; |
| 132 | + } |
| 133 | + |
| 134 | + /// <summary> |
| 135 | + /// Does nothing. Required for implementation of <see cref="IStreamStoreConnection"/>. |
| 136 | + /// </summary> |
| 137 | + /// <param name="stream">This parameter is ignored.</param> |
| 138 | + /// <param name="lastCheckpoint">This parameter is ignored.</param> |
| 139 | + /// <param name="settings">This parameter is ignored.</param> |
| 140 | + /// <param name="eventAppeared">This parameter is ignored.</param> |
| 141 | + /// <param name="liveProcessingStarted">This parameter is ignored.</param> |
| 142 | + /// <param name="subscriptionDropped">This parameter is ignored.</param> |
| 143 | + /// <param name="credentials"></param> |
| 144 | + /// <returns>This connection.</returns> |
| 145 | + public IDisposable SubscribeToStreamFrom(string stream, long? lastCheckpoint, CatchUpSubscriptionSettings settings, Action<RecordedEvent> eventAppeared, Action<Unit> liveProcessingStarted = null, Action<SubscriptionDropReason, Exception> subscriptionDropped = null, UserCredentials credentials = null) |
| 146 | + { |
| 147 | + return this; |
| 148 | + } |
| 149 | + } |
| 150 | +} |
0 commit comments