@@ -14,26 +14,51 @@ public class MockRepositorySpecification : DispatcherSpecification
14
14
public IStreamStoreConnection StreamStoreConnection { get ; }
15
15
public IEventSerializer EventSerializer { get ; }
16
16
public IConfiguredConnection ConfiguredConnection { get ; }
17
- public string Schema { get ; set ; } = "Test" ;
18
17
19
- public MockRepositorySpecification ( )
18
+ private string _schema ;
19
+ public string Schema => _schema ;
20
+
21
+ /// <summary>
22
+ /// Creates a mock repository.
23
+ /// </summary>
24
+ /// <param name="schema">Schema prefix for stream name.</param>
25
+ /// <param name="dataStore">Stream store connection.</param>
26
+ public MockRepositorySpecification ( string schema , IStreamStoreConnection dataStore )
20
27
{
21
- StreamNameBuilder = new PrefixedCamelCaseStreamNameBuilder ( Schema ) ;
22
- StreamStoreConnection = new MockStreamStoreConnection ( Schema ) ;
28
+ _schema = schema ;
29
+ StreamNameBuilder = new PrefixedCamelCaseStreamNameBuilder ( schema ) ;
30
+ StreamStoreConnection = dataStore ;
23
31
StreamStoreConnection . Connect ( ) ;
24
32
EventSerializer = new JsonMessageSerializer ( ) ;
25
33
MockRepository = new StreamStoreRepository ( StreamNameBuilder , StreamStoreConnection , EventSerializer ) ;
26
34
27
35
ConfiguredConnection = new ConfiguredConnection ( StreamStoreConnection , StreamNameBuilder , EventSerializer ) ;
28
36
29
37
var connectorBus = new InMemoryBus ( "connector" ) ;
30
- StreamStoreConnection . SubscribeToAll ( evt => {
31
- if ( evt is ProjectedEvent ) { return ; }
32
- connectorBus . Publish ( ( IMessage ) EventSerializer . Deserialize ( evt ) ) ;
38
+ StreamStoreConnection . SubscribeToAll ( evt =>
39
+ {
40
+ if ( evt is ProjectedEvent ) { return ; }
41
+ connectorBus . Publish ( ( IMessage ) EventSerializer . Deserialize ( evt ) ) ;
33
42
} ) ;
34
43
RepositoryEvents = new TestQueue ( connectorBus , new [ ] { typeof ( Event ) } ) ;
35
44
}
36
45
46
+ /// <summary>
47
+ /// Creates a mock repository with a prefix.
48
+ /// </summary>
49
+ /// <param name="schema">Schema prefix for stream name. Default value is "Test".</param>
50
+ public MockRepositorySpecification ( string schema = "Test" ) : this ( schema , new MockStreamStoreConnection ( schema ) )
51
+ {
52
+ }
53
+
54
+ /// <summary>
55
+ /// Creates a mock repository connected to a StreamStore.
56
+ /// </summary>
57
+ /// <param name="dataStore">Stream store connection.</param>
58
+ public MockRepositorySpecification ( IStreamStoreConnection dataStore ) : this ( "" , dataStore )
59
+ {
60
+ }
61
+
37
62
public virtual void ClearQueues ( )
38
63
{
39
64
RepositoryEvents . Clear ( ) ;
0 commit comments