11using System ;
22using ReactiveDomain . Messaging ;
33using ReactiveDomain . Messaging . Bus ;
4+ using ReactiveDomain . Testing . EventStore ;
45using Xunit ;
56
67namespace ReactiveDomain . Testing
@@ -28,7 +29,7 @@ public void can_get_repository_events()
2829 var aggregate = new TestAggregate ( id ) ;
2930 _fixture . Repository . Save ( aggregate ) ;
3031 _fixture . RepositoryEvents . WaitFor < TestAggregateMessages . NewAggregate > ( TimeSpan . FromMilliseconds ( 500 ) ) ;
31-
32+
3233 _fixture
3334 . RepositoryEvents
3435 . AssertNext < TestAggregateMessages . NewAggregate > ( e => e . AggregateId == id , "Aggregate Id Mismatch" )
@@ -37,7 +38,7 @@ public void can_get_repository_events()
3738
3839 [ Fact ]
3940 public void can_clear_queues ( )
40- {
41+ {
4142 var evt = new TestEvent ( ) ;
4243 _fixture . Dispatcher . Publish ( evt ) ;
4344
@@ -70,6 +71,28 @@ public void can_clear_queues()
7071 . RepositoryEvents
7172 . AssertEmpty ( ) ;
7273 }
74+
75+ [ Fact ]
76+ public void create_mock_repository_without_a_prefix ( )
77+ {
78+ var id = Guid . NewGuid ( ) ;
79+ var expectedStreamName = $ "testAggregate-{ id : n} ";
80+ var mockRepositoryWithoutPrefix = new MockRepositorySpecification ( dataStore : new MockStreamStoreConnection ( "" ) ) ;
81+ var categoryStreamName = mockRepositoryWithoutPrefix . StreamNameBuilder . GenerateForAggregate ( typeof ( TestAggregate ) , id ) ;
82+ Assert . Equal ( expectedStreamName , categoryStreamName ) ;
83+ }
84+
85+ [ Fact ]
86+ public void create_mock_repository_with_a_prefix ( )
87+ {
88+ var prefix = "iamaprefix" ;
89+ var id = Guid . NewGuid ( ) ;
90+ var expectedStreamName = $ "{ prefix } .testAggregate-{ id : n} ";
91+ var mockRepositoryWithoutPrefix = new MockRepositorySpecification ( dataStore : new MockStreamStoreConnection ( prefix ) ) ;
92+ var categoryStreamName = mockRepositoryWithoutPrefix . StreamNameBuilder . GenerateForAggregate ( typeof ( TestAggregate ) , id ) ;
93+ Assert . Equal ( expectedStreamName , categoryStreamName ) ;
94+ }
95+
7396 public CommandResponse Handle ( TestCommands . Command1 command )
7497 {
7598 return command . Succeed ( ) ;
0 commit comments