@@ -29,7 +29,7 @@ public class EstateManagementManagerTests
2929 private readonly Mock < IAggregateRepository < EstateAggregate > > EstateAggregateRepository ;
3030 private readonly Mock < IAggregateRepository < MerchantAggregate > > MerchantAggregateRepository ;
3131 private readonly Mock < IEstateManagementRepository > EstateManagementRepository ;
32-
32+ private readonly Mock < IEventStoreContextManager > EventStoreContextManager ;
3333 private readonly Mock < IModelFactory > ModelFactory ;
3434
3535 private readonly EstateManagementManager EstateManagementManager ;
@@ -40,14 +40,15 @@ public EstateManagementManagerTests()
4040 this . EstateAggregateRepository = new Mock < IAggregateRepository < EstateAggregate > > ( ) ;
4141 this . MerchantAggregateRepository = new Mock < IAggregateRepository < MerchantAggregate > > ( ) ;
4242 this . EstateManagementRepository = new Mock < IEstateManagementRepository > ( ) ;
43+ this . EventStoreContextManager = new Mock < IEventStoreContextManager > ( ) ;
4344
4445 this . ModelFactory = new Mock < IModelFactory > ( ) ;
4546
4647 aggregateRepositoryManager . Setup ( x => x . GetAggregateRepository < EstateAggregate > ( It . IsAny < Guid > ( ) ) ) . Returns ( this . EstateAggregateRepository . Object ) ;
4748 aggregateRepositoryManager . Setup ( x => x . GetAggregateRepository < MerchantAggregate > ( It . IsAny < Guid > ( ) ) ) . Returns ( this . MerchantAggregateRepository . Object ) ;
4849
4950 this . EstateManagementManager =
50- new EstateManagementManager ( aggregateRepositoryManager . Object , this . EstateManagementRepository . Object , this . ModelFactory . Object ) ;
51+ new EstateManagementManager ( aggregateRepositoryManager . Object , this . EstateManagementRepository . Object , this . EventStoreContextManager . Object , this . ModelFactory . Object ) ;
5152 }
5253
5354 [ Fact ]
@@ -117,6 +118,24 @@ public async Task EstateManagementManager_GetMerchant_WithContact_MerchantIsRetu
117118 merchantModel . Contacts . ShouldHaveSingleItem ( ) ;
118119 }
119120
121+ [ Fact ]
122+ public async Task EstateManagementManager_GetMerchantBalance_MerchantBalanceIsReturned ( )
123+ {
124+ Mock < IEventStoreContext > eventStoreContext = new Mock < IEventStoreContext > ( ) ;
125+
126+ String projectionState = "{\r \n \" merchants\" : {\r \n \" " + $ "{ TestData . MerchantId } " + "\" : {\r \n \" MerchantId\" : \" b3054488-ccfc-4bfe-9b0c-ad7ac10b16e8\" ,\r \n \" MerchantName\" : \" Test Merchant 2\" ,\r \n \" AvailableBalance\" : 1000.00,\r \n \" Balance\" : 1000.00,\r \n \" LastDepositDateTime\" : null,\r \n \" LastSaleDateTime\" : null,\r \n \" PendingBalanceUpdates\" : []\r \n }\r \n },\r \n \" debug\" : []\r \n }" ;
127+
128+ eventStoreContext . Setup ( e => e . GetPartitionStateFromProjection ( It . IsAny < String > ( ) , It . IsAny < String > ( ) ) ) . ReturnsAsync ( projectionState ) ;
129+ this . EventStoreContextManager . Setup ( m => m . GetEventStoreContext ( It . IsAny < String > ( ) ) ) . Returns ( eventStoreContext . Object ) ;
130+
131+ var merchantBalanceModel = await this . EstateManagementManager . GetMerchantBalance ( TestData . EstateId , TestData . MerchantId , CancellationToken . None ) ;
132+
133+ merchantBalanceModel . EstateId . ShouldBe ( TestData . EstateId ) ;
134+ merchantBalanceModel . MerchantId . ShouldBe ( TestData . MerchantId ) ;
135+ merchantBalanceModel . AvailableBalance . ShouldBe ( TestData . AvailableBalance ) ;
136+ merchantBalanceModel . Balance . ShouldBe ( TestData . Balance ) ;
137+ }
138+
120139 [ Fact ]
121140 public async Task EstateManagementManager_GetMerchants_MerchantListIsReturned ( )
122141 {
0 commit comments