@@ -14,26 +14,51 @@ public class MockRepositorySpecification : DispatcherSpecification
1414 public IStreamStoreConnection StreamStoreConnection { get ; }
1515 public IEventSerializer EventSerializer { get ; }
1616 public IConfiguredConnection ConfiguredConnection { get ; }
17- public string Schema { get ; set ; } = "Test" ;
1817
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 )
2027 {
21- StreamNameBuilder = new PrefixedCamelCaseStreamNameBuilder ( Schema ) ;
22- StreamStoreConnection = new MockStreamStoreConnection ( Schema ) ;
28+ _schema = schema ;
29+ StreamNameBuilder = new PrefixedCamelCaseStreamNameBuilder ( schema ) ;
30+ StreamStoreConnection = dataStore ;
2331 StreamStoreConnection . Connect ( ) ;
2432 EventSerializer = new JsonMessageSerializer ( ) ;
2533 MockRepository = new StreamStoreRepository ( StreamNameBuilder , StreamStoreConnection , EventSerializer ) ;
2634
2735 ConfiguredConnection = new ConfiguredConnection ( StreamStoreConnection , StreamNameBuilder , EventSerializer ) ;
2836
2937 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 ) ) ;
3342 } ) ;
3443 RepositoryEvents = new TestQueue ( connectorBus , new [ ] { typeof ( Event ) } ) ;
3544 }
3645
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+
3762 public virtual void ClearQueues ( )
3863 {
3964 RepositoryEvents . Clear ( ) ;
0 commit comments